You are given a tree with
Constraints
Subtask 1 [25%]
Subtask 2 [25%]
Subtask 3 [25%]
Subtask 4 [25%]
No additional constraints.
Input Specification
The first line contains
The next
Output Specification
Output the number of possible permutations of values after performing exactly
Sample Input 1
Copy
4 2
1 2
3 1
2 4
Sample Output 1
Copy
5
Explanation for Sample 1
The five possible permutations are listed below as arrays, where the
Sample Input 2
Copy
20 15
9 3
2 4
10 20
1 19
7 20
15 16
11 19
17 16
5 19
16 20
4 17
13 11
6 20
14 17
12 19
18 19
8 3
19 16
3 15
Sample Output 2
Copy
315531008
Explanation for Sample 2
Be sure to output your answer modulo
Comments