#521
Unrated
Counting Graphs
시간 제한
2s
메모리 제한
1024MB
제출
0
정답
0
맞힌 사람
0
정답 비율
0.0%

문제

Bessie has a connected, undirected graph GG with NN vertices labeled 1N1\ldots N and MM edges (2N102,N1MN2+N22\le N\le 10^2, N-1\le M\le \frac{N^2+N}{2}). GG may contain self-loops (edges from nodes back to themselves), but no parallel edges (multiple edges connecting the same endpoints).

Let fG(a,b)f_G(a,b) be a boolean function that evaluates to true if there exists a path from vertex 11 to vertex aa that traverses exactly bb edges for each 1aN1\le a\le N and 0b0\le b, and false otherwise. If an edge is traversed multiple times, it is included that many times in the count.

Elsie wants to copy Bessie. In particular, she wants to construct an undirected graph GG' such that fG(a,b)=fG(a,b)f_{G'}(a,b)=f_G(a,b) for all aa and bb.

Your job is to count the number of distinct graphs GG' that Elsie may create, modulo 109+710^9+7. As with GG, GG' may contain self-loops but no parallel edges (meaning that there are 2N2+N22^{\frac{N^2+N}{2}} distinct graphs on NN labeled vertices in total).

Each input contains TT (1T10541\le T\le \frac{10^5}{4}) test cases that should be solved independently. It is guaranteed that the sum of N2N^2 over all test cases does not exceed 10510^5.

입력

The first line of the input contains TT, the number of test cases.

The first line of each test case contains the integers NN and MM.

The next MM lines of each test case each contain two integers xx and yy (1xyN1\le x\le y\le N), denoting that there exists an edge between xx and yy in GG.

Consecutive test cases are separated by newlines for readability.

출력

For each test case, the number of distinct GG' modulo 109+710^9+7 on a new line.

예제 입력 1

1

5 4
1 2
2 3
1 4
3 5

예제 출력 1

3

예제 입력 2

7

4 6
1 2
2 3
3 4
1 3
2 4
1 4

5 5
1 2
2 3
3 4
4 5
1 5

5 7
1 2
1 3
1 5
2 4
3 3
3 4
4 5

6 6
1 2
2 3
3 4
4 5
5 6
6 6

6 7
1 2
2 3
1 3
1 4
4 5
5 6
1 6

10 10
1 1
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10

22 28
1 2
2 3
3 4
4 5
5 6
6 7
1 7
1 8
3 9
8 10
10 11
10 12
10 13
10 14
11 15
12 16
13 17
14 18
9 15
9 16
9 17
9 18
15 19
19 20
15 20
16 21
21 22
16 22

예제 출력 2

45
35
11
1
15
371842544
256838540

점수

All test cases in input 3 satisfy N5N\le 5.All test cases in inputs 4-5 satisfy M=N1M=N-1.For all test cases in inputs 6-11, if it is not the case that fG(x,b)=fG(y,b)f_G(x,b)=f_G(y,b) for all bb, then there exists bb such that fG(x,b)f_G(x,b) is true and fG(y,b)f_G(y,b) is false. Test cases in inputs 12-20 satisfy no additional constraints.

코드 제출

코드를 제출하려면 로그인이 필요합니다.

로그인
내 제출
제출 내역이 없습니다.
맞은 사람
아직 맞은 사람이 없습니다.
난이도 투표
Unrated0명 투표
로그인 후 AC 받으면 투표할 수 있습니다.
전체 제출
제출 내역이 없습니다.