#SGM0000024. Tập hợp thứ tự (Order statistic set)

Tập hợp thứ tự (Order statistic set)

Order statistic set

Source: SPOJ

Version: Phuoc Hung OJ Extended

Problem Statement

Maintain a dynamic set SS of integers, initially empty. There are QQ operations:

  • I x: insert xx if x∉Sx\notin S.
  • D x: delete xx if x∈Sx\in S.
  • K k: print the kk-th smallest element of SS.
  • C x: print the number of elements of SS smaller than xx.

If K k has k>∣S∣k>|S|, print invalid.

Input

The first line contains QQ.

Each of the next QQ lines contains one operation. For a value parameter xx, ∣x∣≤109|x|\le10^9. For a rank parameter kk, 1≤k≤1091\le k\le10^9.

Output

Print the answer to every K or C query on its own line.

Subtasks

  • Subtask 1 — 20%: 1≤Q≤501\le Q\le50.
  • Subtask 2 — 30%: 1≤Q≤50001\le Q\le5000.
  • Subtask 3 — 50%: 1≤Q≤2⋅1051\le Q\le2\cdot10^5.

Examples

Input

8
I -1
I -1
I 2
C 0
K 2
D -1
K 1
K 2

Output

1
2
2
invalid

Explanation

The sample is processed in order; every printed item/line corresponds to an operation that requires output.