#abc241d. [abc241_d]Sequence Query
[abc241_d]Sequence Query
Problem Statement
We have an empty sequence .
Given queries, process them in order.
Each query is of one of the following three types.
-
1 x
: Insert to . -
2 x k
: Among the elements of that are less than or equal to , print the -th largest value. ( is no more than )
If there are less than elements of that are less than or equal to , then print-1
. -
3 x k
: Among the elements of that are greater than or equal to , print the -th smallest value. ( is no more than )
If there are less than elements of that are greater than or equal to , then print-1
.
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
In the -th query , the type of query (which is either , or ) is given first.
If , then is additionally given; if , then and are additionally given.
In other words, each query is given in one of the following three formats:
Output
Print lines, where is the number of queries such that .
The -th line should contain the answer for the -th such query.
Sample Input 1
11
1 20
1 10
1 30
1 20
3 15 1
3 15 2
3 15 3
3 15 4
2 100 5
1 1
2 100 5
Sample Output 1
20
20
30
-1
-1
1
After have been processed, we have .
For , the elements of greater than or equal to are .
The -st smallest value of them is ; the -nd is ; the -rd is .