#agc005f. [agc005_f]Many Easy Problems
[agc005_f]Many Easy Problems
Problem Statement
#nck { width: 30px; height: auto; }
One day, Takahashi was given the following problem from Aoki:
- You are given a tree with vertices and an integer . The vertices are numbered through . The edges are represented by pairs of integers .
- For a set of vertices in the tree, let be the minimum number of the vertices in a subtree of the given tree that contains all vertices in .
- There are
ways to choose vertices from the trees. For each of them, let be the set of the chosen vertices, and find the sum of over all
ways.
- Since the answer may be extremely large, print it modulo (prime).
Since it was too easy for him, he decided to solve this problem for all .
Constraints
- The given graph is a tree.
Input
The input is given from Standard Input in the following format:
Output
Print lines. The -th line should contain the answer to the problem where , modulo .
Sample Input 1
3
1 2
2 3
Sample Output 1
3
7
3
The diagram above illustrates the case where . The chosen vertices are colored pink, and the subtrees with the minimum number of vertices are enclosed by red lines.
Sample Input 2
4
1 2
1 3
1 4
Sample Output 2
4
15
13
4
Sample Input 3
7
1 2
2 3
2 4
4 5
4 6
6 7
Sample Output 3
7
67
150
179
122
45
7