Given a simple, undirected weighted graph G = (V, E, W), output the weight of its minimum spanning tree.
The input includes multiple test cases. The first of the input is an integer T (T <= 1000) specifying the number of test cases. For each case, the first line contains two integers: the number of the node N and the number of the edges M. In the following M lines, each line contains three integers (si, ei, ci), 1 <= si, ei <= N, 1 <= ci <= 100, representing the indices of end vertices of an edge and the weight of the edge.
Case 1: 2 <= N <= 102, 1 <= M <= 103
Case 2: 2 <= N <= 103, 1 <= M <= 103
Case 3: 2 <= N <= 103, 1 <= M <= 104
Case 4: 2 <= N <= 103, 1 <= M <= 105
For each case, output a single line that indicates the weight of the minimum spanning tree of the graph.