#P7860. Resistance

Resistance

Resistance

Problem Description

You are given a cactus with nn vertices and mm edges. There is a 1 Ohm resistor on every edge. Let f(s,t)f(s,t) be the equivalent resistance between the vertex ss and the vertex tt. Print 1s<tnf(s,t)\sum_{1\leq s<t\leq n} f(s,t). Note: a cactus (sometimes called a cactus tree) is a connected graph in which any two simple cycles have at most one vertex in common. Equivalently, it is a connected graph in which every edge belongs to at most one simple cycle.

Input

The first line contains one integer T(1T7)T (1\leq T\leq 7) - the number of the test cases. For each test case, the first line contains two integers $n,m(1\leq n\leq 2 \times 10^5, 1\leq m\leq 4\times 10^5)$. Each of the following mm lines contains three integers u,v(1uvn)u,v (1\leq u\neq v\leq n).

Output

For each test case, print the answer modulo 109+710^9+7. That is,the answer can be represented as a fraction a/ba/b where (a,b)=1(a,b)=1, output c(0c<109+7)c(0\leq c<10^9+7) such that bca(mod109+7)bc \equiv a \pmod {10^9+7}.

Sample Input

1
4 4
1 2
1 3
2 3
1 4

Sample Output

333333342

Source

2020 Multi-University Training Contest 9