Responsive image

问题 G: Rikka with Match

问题 G: Rikka with Match

时间限制: 13 Sec  内存限制: 128 MB
提交: 1  解决: 1
[提交][状态][讨论版][命题人:]

题目描述

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,E⟩ with n nodes and n−1 edges. Yuta can choose some edges in E and remove them. It is clear that Yuta has 2n−1different 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′ is divisible by m.

It is too difficult for Rikka. Can you help her?  

An edge set S is a match of G=⟨V,E⟩ if and only if each nodes in V connects to at most one edge in S. The maximum matching of graph G is defined as the match of G with the largest size.

输入描述

The first line contains a number t(1≤t≤100), the number of the testcases. And there are no more than 3 testcases with n>1000.

For each testcase, the first line contains two numbers n,m(1≤n≤5×104,1≤m≤200).

Then n−1 lines follow, each line contains two numbers u,v which describes an edge in G.

输出描述

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

样例输入

1
4 2
1 2
2 3
3 4

样例输出

3
[提交][状态]
ACM算法攻关部