#Lutece1189. Leader in Tree Land
Leader in Tree Land
Migrated from Lutece 1189 Leader in Tree Land
All parts of this problem, including description, images, samples, data and checker, might be broken. If you find bugs in this problem, please contact the admins.
Description
Tree land has cities, connected by roads. You can go to any city from any city. In other words, this land is a tree. The city numbered one is the root of this tree.
There are ministers numbered from to . You will send them to cities, one city with one minister.
Since this is a rooted tree, each city is a root of a subtree and there are subtrees. The leader of a subtree is the minister with maximal number in this subtree. As you can see, one minister can be the leader of several subtrees.
One day all the leaders attend a meet, you find that there are exactly ministers. You want to know how many ways to send ministers to each city so that there are ministers attend the meet.
Give your answer mod .
Input
Multiple test cases. In the first line there is an integer , indicating the number of test cases. For each test case, first line contains two numbers . Next line describe the roads of tree land.
Output
For each test case, output one line. The output format is Case #: , is the case number,starting from .
Samples
2
3 2
1 2
1 3
10 8
2 1
3 2
4 1
5 3
6 1
7 3
8 7
9 7
10 6
Case #1: 4
Case #2: 316512
Resources
Prepare for 2015 MU2015 Multi-University Training