#P7484. [2017年杭电多校]Rikka with Match
[2017年杭电多校]Rikka with Match
Rikka with Match
Problem Description
As we know, Rikka is poor at math. Yuta is worrying about this situation, so he gives Rikka some math tasks to practice. There is one of them:
Yuta has an undirected connected graph with nodes and edges. Yuta can choose some edges in and remove them. It is clear that Yuta has different ways to remove.
Now, Yuta want to know the number of ways to remove the edges which make the maximum matching size of the remaining graph is divisible by .
It is too difficult for Rikka. Can you help her?
An edge set is a match of if and only if each nodes in connects to at most one edge in . The maximum matching of graph is defined as the match of with the largest size.
Input
The first line contains a number , the number of the testcases. And there are no more than testcases with . For each testcase, the first line contains two numbers . Then lines follow, each line contains two numbers which describes an edge in .
Output
For each testcase, print a single line with a single number -- the answer modulo .
Sample Input
1
4 2
1 2
2 3
3 4
Sample Output
3
Source
2017 Multi-University Training Contest - Team 5