Queries, Queries Everywhere

Limits 1s, 512 MB

You are given an array aa of length nn. You are also given qq queries on the array and you have to process them. Queries are of two types:

Here is an example of an unweighted complete graph with 44 nodes (note that in our case the edges will have weights).

A spanning tree of a graph is a subset of edges taken from the graph such that they form a tree and every vertex on the graph is reachable from every other vertex via the chosen set of edges. The cost of a spanning tree is just the sum of edge weights in it. A minimum spanning tree of a graph is a spanning tree with the minimum cost.

Input

The first line contains the integer TT (1T100000)(1 \leq T \leq 100000), the number of test cases. For each test case:

The first line contains the integers nn (1n200000)(1 \leq n \leq 200000) and qq (1q100000)(1 \leq q \leq 100000).

The second line contains nn integers describing the contents of the array aa (1a[i]2×109)(1 \leq a[i] \leq 2\times 10^9).

The next qq lines are the queries you have to process in one of the following forms:

The sum of nn over all test cases does not exceed 2×1052\times 10^5. The sum of qq over all test cases does not exceed 10510^5.

Output

For each query of the second type, output a single number in one line - the cost of the MST of the graph constructed.

Don’t print an extra newline after each test case. Every case has at least one query of the second type.

Sample

InputOutput
1
5 6
1 2 3 4 5
1 1 9
1 2 8
1 3 3
1 4 3
1 5 11
2 2 5
22

There can be multiple ways to construct an MST.