We are given a tree with
Additionally, you are given
We need to direct each edge of the tree so that for each given node pair
Input Specification
The first line of input contains the positive integers
Each of the following
The
Output Specification
You must output a single line containing the total number of different ways to direct the edges of the tree that meet the requirement from the task, modulo
Scoring
In test cases worth 20% of total points, the given tree will be a chain. In other words, node
In additional test cases worth 40% of total points, it will hold
Sample Input 1
4 1
1 2
2 3
3 4
2 4
Sample Output 1
4
Sample Input 2
7 2
1 2
1 3
4 2
2 5
6 5
5 7
1 7
2 6
Sample Output 2
8
Sample Input 3
4 3
1 2
1 3
1 4
2 3
2 4
3 4
Sample Output 3
0
Comments