Given an 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 (2 <= n <= 1000) and the number of the edges m(1<=m<=100000). 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.
For each case, output a line that indicates the weight of the minimum spanning tree of the graph.