K-th maximum#687

K-th maximum

1 second
128 megabytes
Very easy

Write a program that implements a data structure that allows adding and removing elements, as well as finding the -th maximum.

Input

The first line contains the number of commands (n \leq 10^5). Each of the next lines contains a single command. Each command is given in the form of two numbers c_i and k_i — the type and argument of the command, respectively (|k_i| \leq 10^9). The supported commands are:

  • : Add an element with key k_i.

  • : Find and output the k_i-th maximum.

  • : Remove the element with key k_i.

It is guaranteed that during processing, it is never required to store elements with equal keys in the structure or remove non-existent elements. It is also guaranteed that, for every query for the k_i-th maximum, it exists.

Output

For each command of type zero, output a single line containing the k_i-th maximum.

Examples

Example 1

Loading
Loading