A new semester has begun, and everyone must have missed RedCapeFlyingCat! RedCapeFlyingCat wants to play a game with all the students taking Data Structures (that is, you, a penguin).
people stand in a circle, numbered clockwise. Person holds a flag.
Passing the flag one step means giving it to the next person clockwise.
Process operations:
insert(k, id): Pass the flag steps. Then add a new person right after the holder (clockwise). The new person takes the flag.erase(k): Pass the flag steps. Then pass it more step, and remove the person who just gave it away. Output the removed person.print(): Output everyone in the circle, clockwise, starting from the holder.The circle is listed clockwise. The flag holder is in bold.
Initially: .
insert(2, 17): The flag moves . Person is added after and takes the flag. Circle: .erase(3): The flag moves , then one more step to . Person is removed, so output 1. Circle: .print(): Output 2 3 17 4 5.The first line contains two integers and — the initial number of people and the number of operations.
Each of the next lines describes one operation in one of the following formats:
insert k iderase kprinterase, the circle has at least peopleprint() operations output at most numbers in total| Subtask | Constraints | Operations |
|---|---|---|
| 1 | , | insert, erase |
| 2 | , | insert, erase, print |
| 3~6 | No additional constraints | insert, erase, print |
For each erase operation, output one line: the number of the removed person.
For each print operation, output one line: the numbers of everyone in the circle, space-separated, clockwise, starting from the flag holder.
Output the lines in the order of the operations.