You are on an undirected connected graph of $$$n$$$ vertices and $$$m$$$ weighted edges. The edges are indexed from $$$1$$$ to $$$m$$$. The $$$i$$$-th edge connects vertex $$$u_i$$$ and $$$v_i$$$, and has weight $$$w_i$$$. You decided to take a wonderful journey around the graph.
Suppose you are at vertex $$$x$$$. You can do the following operations any number of times:
You are now at vertex $$$1$$$, and you need to mark every edge at least once and return to vertex $$$1$$$. Calculate the minimum cost.
Please note the cost for transferring is not the maximum weight on the path, nor the maximum index itself. If you have any questions, refer to the Note section below.
Each test contains multiple test cases. The first line contains the number of test cases $$$T$$$ ($$$1 \le T \le 10^4$$$). The description of the test cases follows.
The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 10^6$$$, $$$0 \le m \le 10^6$$$).
Then $$$m$$$ lines, the $$$i$$$-th line contains three integers $$$u_i, v_i, w_i$$$ ($$$1 \le u_i, v_i \le n$$$, $$$1 \le w \le 10^9$$$) — meaning that the edge with index $$$i$$$ is between vertex $$$u_i$$$ and vertex $$$v_i$$$ with weight $$$w_i$$$.
It's guaranteed that the described graph is connected.
Also note that the graph may have self-loops and multiple edges.
It is guaranteed that the sums of $$$n$$$ and $$$m$$$ over all test cases do not exceed $$$10^6$$$ each.
For each test case output one integer — the minimum cost.
55 62 4 152 5 41 3 62 3 91 2 103 4 74 31 2 31 3 21 4 12 31 2 12 1 31 1 46 62 3 101 3 105 6 106 6 14 5 103 4 105 51 2 45 1 54 3 62 4 101 4 7
58887143
Let $$$u \xrightarrow{e} v$$$ denote going to vertex $$$v$$$ from vertex $$$u$$$ by edge $$$e$$$.
In the first test case, one possible solution is:
The total cost is $$$6+7+15+9+7+4+10=58$$$.
In the second test case, one possible solution is: