Maximum Weighted Matching

에지를 복사하고 세분화하는 과정으로 만들어진 그래프에서 최대 가중 매칭의 가중치 합과 그러한 최대 매칭의 개수를 10^9+7로 나눈 나머지를 구한다.

어려움9동적 계획법트리DFS조합론아직 제출이 없습니다시간 제한4초메모리 제한256 MB

문제

Chiaki 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)(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,,t_kt\_1,t\_2,\dots,t\_k, Chiaki would insert edges (u,t_1)(u,t\_1), (t_1,t_2)(t\_1,t\_2), \dots, (t_k1,t_k)(t\_{k-1}, t\_k), (t_k,v)(t\_k, v) into the graph).

Given 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 (109+7)10^9 + 7)).

A 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.

A maximum weighted matching is defined as a matching where the sum of the values of the edges in the matching have a maximal value.

입력

There are multiple test cases. The first line of input contains an integer TT, indicating the number of test cases. For each test case:

The first line contains two integers nn and mm (1n,m1051 \le n, m \le 10^5) -- the number of vertices and the number of edges.

Each of the next mm lines contains three integers u_iu\_i, v_iv\_i and w_iw\_i (1u_i,v_in,1w_i1091 \le u\_i, v\_i \le n, 1 \le w\_i \le 10^9) -- deonting  an edge between u_iu\_i and v_iv\_i with weight w_iw\_i.

It is guaranteed that neither the sum of all nn nor the sum of all mm exceeds 10610^6.

출력

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 (109+710^9 + 7).