Time Limit: 2 sec / Memory Limit: 1024 MB
Score : 400400 points
Problem Statement
�N people, with ID numbers 11, 22, ……, �N, are lining up in front of a bank.
There will be �Q events. The following three kinds of events can happen.
1
: The teller calls the person with the smallest ID number who has not been called.2 x
: The person with the ID number �x comes to the teller for the first time. (Here, person �x has already been called by the teller at least once.)3
: The teller again calls the person with the smallest ID number who has already been called but has not come.
Print the ID numbers of the people called by the teller in events of the third kind.
Constraints
- 1≤�≤5×1051≤N≤5×105
- 2≤�≤5×1052≤Q≤5×105
- There will not be an event of the first kind when all people have already been called at least once.
- For each event of the second kind, the person with the ID number �x has already been called by the teller at least once.
- For each event of the second kind, the person with the ID number �x will not come to the teller more than once.
- There will not be an event of the third kind when all people who have already been called have come to the teller.
- There is at least one event of the third kind.
- All values in the input are integers.
Input
The input is given from Standard Input in the following format, where event�eventi denotes the �i-th event:
�N �Q event1event1 event2event2 ⋮⋮ event�eventQ
The description of each event