 Reverse Delete Algorithm for Minimum Spanning Tree
Medium Accuracy: 32.34% Submissions: 796 Points: 4

Reverse Delete algorithm is closely related to Kruskal’s algorithm. In Reverse Delete algorithm, we sort all edges in decreasing order of their weights. After sorting, we one by one pick edges in decreasing order. We include current picked edge if excluding current edge causes disconnection in current graph. The main idea is delete edge if its deletion does not lead to disconnection of graph. Your task is to print the value of total weight of Minimum Spanning Tree formed.

Input:
The first line of the input contains an integer 'T' denoting the number of test cases. Then 'T' test cases follow. Each test case consists of two lines.
Description of  test cases is as follows:
The First line of each test case contains two integers 'V' and 'E'  which denotes the no of vertices and no of edges respectively.
The Second line of each test case contains 'E'  space separated triplets of m , n and w denoting that there is an edge from m to n and their weights.

Output:
Print the desired output in each line.

Constraints:
1<=T<=100
1<=V,E<=100
1<=m,n<=V
1<=w<=100

Example:
Input:

1
4 5
0 1 10 0 2 6 0 3 5 1 3 15 2 3 4

Output:
19 