{"trustable":true,"prependHtml":"\u003cscript\u003e window.katexOptions \u003d { disable: true }; \u003c/script\u003e\n\u003cscript type\u003d\"text/x-mathjax-config\"\u003e\n MathJax.Hub.Config({\n tex2jax: {\n inlineMath: [[\u0027$$$\u0027,\u0027$$$\u0027], [\u0027$\u0027,\u0027$\u0027]],\n displayMath: [[\u0027$$$$$$\u0027,\u0027$$$$$$\u0027], [\u0027$$\u0027,\u0027$$\u0027]]\n }\n });\n\u003c/script\u003e\n\u003cscript async src\u003d\"https://mathjax.codeforces.org/MathJax.js?config\u003dTeX-AMS-MML_HTMLorMML\" type\u003d\"text/javascript\"\u003e\u003c/script\u003e","sections":[{"title":"","value":{"format":"HTML","content":"\u003cdiv class\u003d\"panel_content\"\u003eWayne 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.\u003cbr\u003e\u003cbr\u003eWayne 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:\u003cbr\u003e\u003cbr\u003e$$\\sum_{1 \\leq s \u0026lt; t \\leq n}{\\left(s \\oplus t \\oplus \\mathrm{flow}(s, t)\\right)},$$\u003cbr\u003e\u003cbr\u003ewhere $\\oplus$ means the bitwise exclusive-OR operator and $\\mathrm{flow}(s, t)$ means the maximum bits that could be transmitted per second between vertex $s$ and vertex $t$.\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"The first line contains one integer $T$, indicating the number of test cases.\u003cbr\u003eThe following lines describe all the test cases. For each test case:\u003cbr\u003eThe first line contains two integers $n$ and $m$.\u003cbr\u003eEach 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.\u003cbr\u003e$1 \\leq T \\leq 100$, $1 \\leq n \\leq 10^5$, $n - 1 \\leq m \\leq \\frac{3}{2}(n - 1)$, $1 \\leq u, v \\leq n$, $u \\neq v$, $0 \\leq w \u0026lt; 10^9$.\u003cbr\u003eIt is guaranteed that the sum of $n$ in all test cases does not exceed $10^6$ and the size of the standard input file does not exceed $26$ MiB."}},{"title":"Output","value":{"format":"HTML","content":"For each test case, print the answer in one line.\u003cbr\u003e"}},{"title":"Sample","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e2\r\n3 3\r\n1 2 5\r\n2 3 6\r\n3 1 5\r\n5 6\r\n1 2 5\r\n2 3 6\r\n3 1 5\r\n3 4 6\r\n4 5 5\r\n5 3 6\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e27\r\n116\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}},{"title":"Hint","value":{"format":"HTML","content":"\u003cbr\u003eFor the first sample, flow(1, 2) \u003d flow(1, 3) \u003d 10, flow(2, 3) \u003d 11.\u003cbr\u003e"}}]}