atcoder#ABC294D. [ABC294D] Bank
[ABC294D] Bank
Score : points
Problem Statement
people, with ID numbers , , , , are lining up in front of a bank. There will be 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 comes to the teller for the first time. (Here, person 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
- 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 has already been called by the teller at least once.
- For each event of the second kind, the person with the ID number 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 denotes the -th event:
The description of each event is in one of the following formats:
1
2
3
Output
Print lines, where is the number of events of the third kind. The -th line should contain the ID number of the person called in the -th event of the third kind.
4 10
1
1
3
2 1
1
2 3
3
1
2 2
3
1
2
4
For each , shown below is the set of people who have already been called but have not come just before the -th event.
- :
- :
- :
- :
- :
- :
- :
- :
- :
- :
The events for are of the third kind, so you should print the persons with the smallest ID numbers in the sets for those events: .