#K76647. Bookshelf Queries

    ID: 34689 Type: Default 1000ms 256MiB

Bookshelf Queries

Bookshelf Queries

You are given a bookshelf that can store books identified by a unique integer identifier. The bookshelf supports the following three types of operations:

  • Add Book: "1 X" — Add a book with identifier X to the shelf.
  • Remove Book: "2 X" — Remove the book with identifier X from the shelf. If the book does not exist, do nothing.
  • Query Book: "3 K" — Query the k-th smallest book on the shelf. The result is defined as the k-th element in the sorted order of book identifiers. If no such book exists, output -1. Here, the k-th smallest book is denoted as \(a_{(k)}\) where \(1 \leq k \leq n\) and \(n\) is the number of books on the shelf.

You will be given a series of operations, and your task is to process these operations accordingly. For every query operation (type 3), output the answer on a new line.

inputFormat

The input is given via standard input. The first line contains a single integer N representing the number of operations. The following N lines each contain an operation in one of the following forms:

  • 1 X — Add a book with identifier X.
  • 2 X — Remove the book with identifier X.
  • 3 K — Query the k-th smallest book on the shelf.

outputFormat

For each query operation (type 3), output the result on its own line. If the queried book does not exist, output -1.

## sample
4
1 5
1 2
1 9
3 2
5