13451 - K-th largest   

Description

Mr. Kuo is an adventurer. One day, he finds a sequences of operations and an empty set S.

Each operation is one of the following two types,

  1. Insert x:insert x into S. Duplicate element is legal.
  2. Query x k:Among the elements of S that are greater or equal to x, what is the k-th smallest value?

 

Mr. Kuo is curious about the answer to each operation 2, so he asks for your help.

 

Hint:You can refer to C++ upper_bound function

Input

The input consists of multiple lines.

Each line is given in one of the following two format:

  1. Insert x
  2. Query x k

 

There will be at most 100000 operations in the sequences.

1 ≤ x ≤ 109

1 ≤ k ≤ 5

 

Output

For each operation of type 2, print the k-th smallest value among the elements of S that are greater than or equal to x.

If there are less than k elements of S that are greater than or equal to x, then print "-1".

Remember to print '\n' at the end of each line.

 

Sample Input  Download

Sample Output  Download

Tags




Discuss