Problem C: Heap

Problem C: Heap

Time Limit: 1 Sec  Memory Limit: 512 MB
Submit: 1555  Solved: 174
[Submit][Status][Web Board]

Description

There is a set with size n initially, and there are q operations, each operation will be one of the following cases:

Add x: add x to this set.

Delete: delete the minimum element of the set.

Query: print the minimum element of the set.

Input

The first line will be an integer T, which is the number of test cases. (1 <= T <= 10). For each test case, the first line will be an integer n(1 <= n <= 106), then the second line will be n integers, they make up the initial set. The third line will be an integer q(1 <= q <= 105), it means the number of operations. Then followed by q lines, each line will be one of the following cases:

1 x: Add x.

2: Delete.

3: Query.

Output

For each “Query”, print the minimum element of the set.

Sample Input

1
1
1
1
3

Sample Output

1

HINT

We guarantee that all values are less than or equal to 109.

[Submit][Status]