Permutation

Time Limit: 1000ms
Memory Limit: 65536KB
This problem will be judged on HDU. Original ID: 5789
64-bit integer IO format: %I64d      Java class name: Main

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 $N(1\leq N\leq 50)$,$ROOT(1\leq ROOT\leq N)$. 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

Source

Language: 
Theme: 
Share Code? 

Powered by NB231 | Current Style: .