#abc217e. [abc217_e]Sorting Queries
[abc217_e]Sorting Queries
Problem Statement
We have an empty sequence . You will be given queries, which should be processed in the order they are given. Each query is of one of the three kinds below:
1 x
: Append to the end of .2
: Print the element at the beginning of . Then, delete that element. It is guaranteed that will not empty when this query is given.3
: Sort in ascending order.
Constraints
- will not be empty when a query
2
is given. - All values in input are integers.
Input
Input is given from Standard Input in the following format:
The -th query, , begins with the kind of query (, , or ). If , the line additionally has an integer .
In other words, each query is in one of the three formats below.
Output
Print lines, where is the number of queries with .
The -th line should contain the response for the -th such query.
Sample Input 1
8
1 4
1 3
1 2
1 1
3
2
1 0
2
Sample Output 1
1
2
The -th line below shows the contents of after the -th query is processed in Sample Input .
Sample Input 2
9
1 5
1 5
1 3
2
3
2
1 6
3
2
Sample Output 2
5
3
5
The -th line below shows the contents of after the -th query is processed in Sample Input .