14371 - 2024_DS_Summer_Assignment3_pC   

Description

Maintain an integer ordered set S, which support the following operations:

  • INS k: Insert k to S. If k is already in S, do nothing.
  • DEL k: Delete the element in S with value k. If k is not in S, do nothing.
  • IND k: Find the k-th smallest element in S, or report that the cardinality of S is smaller than k.

Input

The first line contains an integer q, representing the number of operations. Each of the following q lines is a single operation mentioned above.

Constraint

  • 1 <= q <= 3 x 105
  • 1 <= k <= 109 for every operation

Output

For each IND k operations, output the answer in each line. If the cardinality of S is smaller than k. output -1.

Sample Input  Download

Sample Output  Download

Tags




Discuss