Score : $500$ points
We have an empty sequence $A$. You will be given $Q$ queries, which should be processed in the order they are given. Each query is of one of the three kinds below:
1 x
: Append $x$ to the end of $A$.2
: Print the element at the beginning of $A$. Then, delete that element. It is guaranteed that $A$ will not empty when this query is given.3
: Sort $A$ in ascending order.2
is given.Input is given from Standard Input in the following format:
$Q$ $\mathrm{query} 1$ $\mathrm{query} 2$ $\vdots$ $\mathrm{query} Q$
The $i$-th query, $\mathrm{query} i$, begins with the kind of query $c_i$ ($1$, $2$, or $3$). If $c_i = 1$, the line additionally has an integer $x$.
In other words, each query is in one of the three formats below.
$1$ $x$
$2$
$3$
Print $q$ lines, where $q$ is the number of queries with $c_i = 2$.
The $j$-th line $(1 \leq j \leq q)$ should contain the response for the $j$-th such query.
8 1 4 1 3 1 2 1 1 3 2 1 0 2
1 2
The $i$-th line below shows the contents of $A$ after the $i$-th query is processed in Sample Input $1$.
9 1 5 1 5 1 3 2 3 2 1 6 3 2
5 3 5
The $i$-th line below shows the contents of $A$ after the $i$-th query is processed in Sample Input $2$.