A scoring ledger maintains a multiset of scores, each an integer from 1 to 50. Starting empty, it processes q operations, each one of:
INSERT x— add one occurrence of scorex.ERASE x— remove one occurrence of scorex. It is guaranteed at least one occurrence exists.RANK x— report how many scores currently in the multiset are strictly less thanx.KTH k— report thek-th smallest score currently in the multiset (1-indexed, counting duplicates). It is guaranteed1 <= k <=the current size.
Input format
Line 1: an integer q.
Next q lines: INSERT x, ERASE x, RANK x, or KTH k.
Output format
For every RANK and every KTH operation, in order, print the requested integer on its own line.
Constraints
- 1 <= q <= 40
- 1 <= x <= 50
- 1 <= k <= current multiset size