[USACO Open 2020 P]Circus
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld

题目描述

The N cows of Farmer John's Circus (1≤N≤105) are preparing their upcoming acts. The acts all take place on a tree with vertices labeled 1…N. The "starting state" of an act is defined by a number 1≤K≤N and an assignment of cows 1…K to the vertices of the tree, so that no two cows are located at the same vertex.
In an act, the cows make an arbitrarily large number of "moves." In a move, a single cow moves from her current vertex to an unoccupied adjacent vertex. Two starting states are said to be equivalent if one may be reached from the other by some sequence of moves.

For each 1≤K≤N, help the cows determine the number of equivalence classes of starting states: that is, the maximum number of starting states they can pick such that no two are equivalent. Since these numbers may be very large, output their remainders modulo 109+7.

输入描述:

Line 1 contains N.
Lines 2≤i≤N each contain two integers ai and bi denoting an edge between ai and bi in the tree.

输出描述:

For each 1≤i≤N, the i-th line of output should contain the answer for K=i modulo 109+7.
示例1

输入

复制
5
1 2
2 3
3 4
3 5

输出

复制
1
1
3
24
120

说明

For K=1 and K=2, any two states can be transformed into one another.
Now consider K=3, and let ci denote the location of cow i. The state (c1,c2,c3)=(1,2,3) is equivalent to the states (1,2,5) and (1,3,2). However, it is not equivalent to the state (2,1,3).