{"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\"\u003eChiaki is good at generating special graphs. Initially, she has a graph with only two vertices connected by an edge. Each time, she can choose an edge $(u,v)$, make a copy of it, insert some new vertices (maybe zero) in the edge (i.e. let the new vertices be $t_1,t_2,\\dots,t_k$, Chiaki would insert edges $(u,t_1)$, $(t_1,t_2)$, $(t_{k-1}, t_k)$, $(t_k, v)$ into the graph).\u003cbr\u003eGiven a weighted graph generated by above operations, Chiaki would like to know the maximum weighted matching of the graph and the number different maximum weighted matchings modulo ($10^9 + 7)$).\u003cbr\u003eA matching in a graph is a set of pairwise non-adjacent edges, none of which are loops; that is, no two edges share a common vertex.\u003cbr\u003eA maximum weighted matching is defined as a matching where the sum of the values of the edges in the matching have a maximal value.\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"There are multiple test cases. The first line of input contains an integer $T$, indicating the number of test cases. For each test case:\u003cbr\u003eThe first line contains two integers $n$ and $m$ ($1 \\le n, m \\le 10^5$) -- the number of vertices and the number of edges.\u003cbr\u003eEach of the next $m$ lines contains three integers $u_i$, $v_i$ and $w_i$ ($1 \\le u_i, v_i \\le n, 1 \\le w_i \\le 10^9$) -- deonting an edge between $u_i$ and $v_i$ with weight $w_i$.\u003cbr\u003eIt is guaranteed that neither the sum of all $n$ nor the sum of all $m$ exceeds $10^6$."}},{"title":"Output","value":{"format":"HTML","content":"For each test case, output two integers separated by a single space. The first one is the sum of weight and the second one is the number of different maximum weighted matchings modulo ($10^9 + 7$).\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\n6 7\r\n1 2 1\r\n2 3 1\r\n4 5 1\r\n5 6 1\r\n1 4 1\r\n2 5 1\r\n3 6 1\r\n4 5\r\n1 2 1\r\n1 3 1\r\n1 4 1\r\n2 3 1\r\n3 4 1\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e3 3\r\n2 2\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}