문제
Bessie has a connected, undirected graph with vertices labeled and edges (). may contain self-loops (edges from nodes back to themselves), but no parallel edges (multiple edges connecting the same endpoints).
Let be a boolean function that evaluates to true if there exists a path from vertex to vertex that traverses exactly edges for each and , 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 such that for all and .
Your job is to count the number of distinct graphs that Elsie may create, modulo . As with , may contain self-loops but no parallel edges (meaning that there are distinct graphs on labeled vertices in total).
Each input contains () test cases that should be solved independently. It is guaranteed that the sum of over all test cases does not exceed .
입력
The first line of the input contains , the number of test cases.
The first line of each test case contains the integers and .
The next lines of each test case each contain two integers and (), denoting that there exists an edge between and in .
Consecutive test cases are separated by newlines for readability.
출력
For each test case, the number of distinct modulo 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 .All test cases in inputs 4-5 satisfy .For all test cases in inputs 6-11, if it is not the case that for all , then there exists such that is true and is false. Test cases in inputs 12-20 satisfy no additional constraints.
코드를 제출하려면 로그인이 필요합니다.
로그인