Wayne is an administrator of some metropolitan area network. The network he managed can be formed into a simple connected graph with n vertices and m edges, which means the graph does not contain any self-loop and there is at most one edge and at least one path between every two vertices. Furthermore, the network also meets the condition there are at most two non-intersect paths, which share no common edges, between every two vertices.
Wayne knows the bandwidth of each edge in that network but it is not enough for him. He needs plenty of statistic data to display, for example, he wants to know what the maximum data rate between every two vertices is. For the sake of clarity, vertices in that are numbered from 1 to n and the maximum bits each edge could transmit per second will be given. Your task is assisting him to calculate the value of the following formula:
where means the bitwise exclusive-OR operator and means the maximum bits that could be transmitted per second between vertex s and vertex t.
The first line contains one integer T, indicating the number of test cases.
The following lines describe all the test cases. For each test case:
The first line contains two integers n and m.
Each of the following m lines contains three integers u, v and w, indicating a bidirectional edge between vertex u and vertex v that can transmit at most w bits per second in each direction.
1 ≤ T ≤ 100, 1 ≤ n ≤ 105, , 1 ≤ u, v ≤ n, u ≠ v, 0 ≤ w < 109.
It is guaranteed that the sum of n in all test cases does not exceed 106 and the size of the standard input file does not exceed 26 MiB.
For each test case, print the answer in one line.
For the first sample, , .
## Input
The first line contains one integer T, indicating the number of test cases.The following lines describe all the test cases. For each test case:The first line contains two integers n and m.Each of the following m lines contains three integers u, v and w, indicating a bidirectional edge between vertex u and vertex v that can transmit at most w bits per second in each direction.1 ≤ T ≤ 100, 1 ≤ n ≤ 105, , 1 ≤ u, v ≤ n, u ≠ v, 0 ≤ w < 109.It is guaranteed that the sum of n in all test cases does not exceed 106 and the size of the standard input file does not exceed 26 MiB.
## Output
For each test case, print the answer in one line.
[samples]
## Note
For the first sample, , .
**Definitions**
Let $ T \in \mathbb{Z} $ be the number of test cases.
For each test case:
- Let $ n \in \mathbb{Z} $ be the number of vertices, $ m \in \mathbb{Z} $ the number of edges.
- Let $ G = (V, E) $ be a simple, connected, undirected graph with $ V = \{1, 2, \dots, n\} $, and edge set $ E \subseteq \binom{V}{2} $.
- Each edge $ e = (u, v) \in E $ has a weight $ w(e) \in \mathbb{Z}_{\geq 0} $, representing the maximum bandwidth (bits per second) between $ u $ and $ v $.
**Constraints**
1. $ 1 \leq T \leq 100 $
2. $ 1 \leq n \leq 10^5 $, $ n-1 \leq m \leq \frac{n(n-1)}{2} $
3. $ 1 \leq u, v \leq n $, $ u \neq v $, $ 0 \leq w < 10^9 $
4. The graph is connected and for every pair of vertices, there are at most two edge-disjoint paths between them.
5. The sum of all $ n $ across test cases $ \leq 10^6 $.
**Objective**
For each test case, compute:
$$
\sum_{1 \leq s < t \leq n} \left( \text{maxflow}(s, t) \oplus (s \oplus t) \right)
$$
where:
- $ \text{maxflow}(s, t) $ is the maximum flow (i.e., edge-disjoint path capacity sum) between vertices $ s $ and $ t $,
- $ \oplus $ denotes the bitwise XOR operator.
**Note**: Due to the constraint that there are at most two edge-disjoint paths between any pair of vertices, $ \text{maxflow}(s, t) $ is the sum of the capacities of the two most capacity-efficient edge-disjoint paths (or one if only one exists).