#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 G=V,EG=\langle V,E \rangle with nn nodes and n1n-1 edges. Yuta can choose some edges in EE and remove them. It is clear that Yuta has 2n12^{n-1} 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 G¡¯G¡¯ is divisible by mm. It is too difficult for Rikka. Can you help her?
An edge set SS is a match of G=V,EG=\langle V,E \rangle if and only if each nodes in VV connects to at most one edge in SS. The maximum matching of graph GG is defined as the match of GG with the largest size.

Input

The first line contains a number t(1t100)t(1 \leq t \leq 100), the number of the testcases. And there are no more than 33 testcases with n>1000n > 1000. For each testcase, the first line contains two numbers n,m(1n5×104,1m200)n,m(1 \leq n \leq 5 \times 10^4,1 \leq m \leq 200). Then n1n-1 lines follow, each line contains two numbers u,vu,v which describes an edge in GG.

Output

For each testcase, print a single line with a single number -- the answer modulo 998244353998244353.

Sample Input

1
4 2
1 2
2 3
3 4

Sample Output

3

Source

2017 Multi-University Training Contest - Team 5

https://acm.hdu.edu.cn/showproblem.php?pid=6091