#P11048. [2016杭电多校]Permutation
[2016杭电多校]Permutation
Permutation
Problem Description
Alice get a rooted tree that has N nodes. Every node has an unique id from 1 to N. Alice want to change the tree to a permutation. If for all nodes, all sons in its subtree is before it, we call the permutation is good. Now Alice wanna know the sum of the number of inversion pair of all good permutations. Output the answer mod 1000000007.
Input
The input contains multiple test cases. For each test case, the first line contains two integers ,. Then N-1 lines, every line contains two integers U, V. The given tree is legal.
Output
For each test case output the answer mod 1000000007.
Sample Input
3 1
1 2
1 3
4 1
1 2
1 3
1 4
Sample Output
5
27
Author
ZSTU
Source
2016 Multi-University Training Contest 5