14220 - Do you wanna play a game ? (version 2)
|
Time |
Memory |
Case 1 |
1 sec |
512 MB |
Case 2 |
1 sec |
512 MB |
Case 3 |
1 sec |
512 MB |
Case 4 |
1 sec |
512 MB |
Case 5 |
1 sec |
512 MB |
Case 6 |
1 sec |
512 MB |
Description
TA Penguin07 wants to play a game with N people. Initially, these N people are lined up and numbered from 1 to N.
TA Penguin07 will issue K commands, commands i is represented as a pair of integers (Ti, Ai, Bi), and is the following operation:
- If Ti = 1, the person with number Ai have to kill min(C, Bi) people behind them. Here, C represents the number of people remaining behind them at the moment of the command.
- If Ti = 2, the person with number Ai have to kill min(C, Bi) people in front of them. In this case, C represents the number of people remaining in front of them at the moment of the command.
However, Penguin07 has poor eyesight and cannot clearly see who has been killed from the long line. So, after each command issued by Penguin07, you need to tell Penguin07 who was killed.
If the command is invalid (that person has already been killed or there is no one been killed), you should output "Penguin07 QQ" (with no quotes).
Input
The first line contains two positive integers, N and K.
The following K lines, each line represents a command in the format of three integers: (Ti, Ai, Bi).
Constraints
- Testcases 1 ~ 4: Ti = 1, Bi = 1
- Testcases 5 ~ 6: satisfy no additional constraints.
- For all test cases: 1 ≤ N, K ≤ 2 * 106, 1 ≤ Ti ≤ 2, 1 ≤ Bi ≤ 109, 1 ≤ Ai ≤ N
Output
For every operation, output the numbers of the people killed in increasing order.
If an operation is invalid, output "Penguin07 QQ" (without quotes).
Remember to print a ‘\n’ at the end of the output.
Do not include any spaces at the end of line.
Tags