#P6277. [USACO20OPEN] Circus P

[USACO20OPEN] Circus P

Description

The NN cows in Farmer John's circus are preparing for an upcoming show. The entire show takes place on a tree with nodes numbered 1N1\ldots N. An "initial state" of the show is defined by an integer KK (1KN1\leq K\leq N), where cows 1K1\ldots K are placed on nodes of the tree, and no two cows are on the same node.

During a show, the cows may "move" any number of times. In one "move", a cow can move from its current node to an unoccupied adjacent node. If one state can be reached from another through a sequence of moves, then we say these two initial states are equivalent.

For each 1KN1\leq K\leq N, you need to help the cows determine how many equivalence classes of initial states there are. In other words, find the maximum number of initial states such that they are pairwise not equivalent. Since the number may be large, output the answer mod 109+7\bmod \ 10^9+7.

Input Format

The first line contains an integer NN.

The next N1N-1 lines each contain two integers ai,bia_i,b_i, indicating that there is an edge in the tree connecting aia_i and bib_i.

Output Format

Output a total of NN lines. For each 1iN1\leq i\leq N, on line ii output the answer for K=iK=i, taken mod 109+7\bmod \ 10^9+7.

5
1 2
2 3
3 4
3 5
1
1
3
24
120
8
1 3
2 3
3 4
4 5
5 6
6 7
6 8
1
1
1
6
30
180
5040
40320

Hint

Explanation of Sample 11:

For K=1K=1 and K=2K=2, any two states can be reached from each other.

Now consider K=3K=3. Let cic_i denote the position of cow ii. Then the state (c1,c2,c3)=(1,2,3)(c_1,c_2,c_3)=(1,2,3) is equivalent to the states (1,2,5)(1,2,5) and (1,3,2)(1,3,2), but it is not equivalent to the state (2,1,3)(2,1,3).


For 100%100\% of the testdata, it is guaranteed that 1N1051 \le N \le 10^5.

There are 2020 test points. Among them, 121\sim 2 are the samples, and the remaining points have the following properties:

For test points 343 \sim 4, N8N \leq 8.
For test points 575 \sim 7, N16N \leq 16.
For test points 8108 \sim 10, N100N \leq 100, and the tree is a "star": at most one node has degree greater than 22.
For test points 111511 \sim 15, N100N \leq 100.
For test points 162016 \sim 20, there are no special restrictions.


Problem setter: Dhruv Rohatgi

Translated by ChatGPT 5