文理学院程序设计在线练习


Don’s Candies

Time Limit: 1 Second(s)    Memory Limit: 32 MB

Total Submission(s): 37   Accepted Submission(s): 1
Problem Description

DON has a magic pocket. DON can put a candy in the pocket or take out a candy from it. Different candies may have different size. At some time, DON wants to know the size of the Kth smallest candy in the pocket. Can you help him?

Input

The first row of the data is T, the number of data groups.
In each set of data: one integer m represents the number of operations.
Then there are m rows, each with two integers OP and X.
When OP is 1, put a candy of volume X into the pocket.
When OP is 2, take a candy of volume X out of your pocket.
When OP is 3, query the Kth smallest candy in the pocket.
When taking out the candy, make sure you have the candy in your pocket.
Ensure that 1<=T<=10,1 < = m < = 100000, 1 < = x < = 100000, 1 < = k < = MAX_NUM. Where MAX_NUM is the number of sweets in the pocket.

Output

For each set of data, print a line answer when OP is 3.

Sample Input
2
3
1 2
1 2
3 1
4
1 2
1 3
2 2
3 1
Sample Output
2
3
Source

2019绍兴市计算机技能竞赛