| TheForces Round #37 (Brute-Forces1) |
|---|
| Finished |
You are given a rooted tree containing $$$n$$$ nodes and rooted at node $$$1$$$.
Now your task is to count the number of different permutations $$$p$$$ of length $$$n$$$ which satisfies the following condition :
$$$^\dagger$$$ Node $$$a$$$ is an ancestor of node $$$b$$$ if the shortest path from $$$b$$$ to the root passes through $$$a$$$.
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10^3$$$). The description of the test cases follows.
The first line of each test case contains a single integer $$$n$$$ $$$(3 \le n \le 5000)$$$ — the size of the tree.
The next $$$n-1$$$ lines contain two integers $$$x,y$$$ $$$(1 \le x,y \le n, x≠y)$$$ — there is an edge between $$$x$$$ and $$$y$$$.
It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$5000$$$.
For each test case, print a single integer — the required count modulo $$$10^9 + 7$$$.
231 31 254 51 43 12 4
2 4
For the first test case, the permutations which satisfies the condition are :
For the second test case, the permutations which satisfies the condition are :
| Name |
|---|


