7593: Resistance

内存限制:128 MB 时间限制:2 S 标准输入输出
题目类型:传统 评测方式:文本比较 上传者:
提交:0 通过:0

题目描述

You are given a cactus with n vertices and m edges. There is a 1 Ohm resistor on every edge.

Let f(s,t) be the equivalent resistance between the vertex s and the vertex t .

Print 1s<tnf(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.

输入格式

The first line contains one integer T(1T7) - the number of the test cases.

For each test case, the first line contains two integers n,m(1n2×105,1m4×105) .

Each of the following m lines contains three integers u,v(1uvn) .
 

输出格式

For each test case, print the answer modulo 109+7 . That is,the answer can be represented as a fraction a/b where (a,b)=1 , output c(0c<109+7) such that bca(mod109+7) .

输入样例 复制

1
4 4
1 2
1 3
2 3
1 4

输出样例 复制

333333342