atcoder#ABC207F. [ABC207F] Tree Patrolling
[ABC207F] Tree Patrolling
Score : points
Problem Statement
You have a tree with vertices, numbered through . The -th edge connects Vertex and Vertex .
You will choose some vertices (possibly none) and place a takahashi in each of them to guard the tree. A takahashi placed at Vertex will guard itself and the vertices directly connected to by an edge.
There are ways to choose vertices for placing takahashi. In how many of them will there be exactly vertices guarded by one or more takahashi?
Find this count and print it modulo for each .
Constraints
- The given graph is a tree.
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print lines. The -th line should contain the answer for .
3
1 3
1 2
1
0
2
5
There are eight ways to choose vertices for placing takahashi, as follows:
- Place a takahashi at no vertices, guarding no vertices.
- Place a takahashi at Vertex , guarding all vertices.
- Place a takahashi at Vertex , guarding Vertices and .
- Place a takahashi at Vertex , guarding Vertices and .
- Place a takahashi at Vertices and , guarding all vertices.
- Place a takahashi at Vertices and , guarding all vertices.
- Place a takahashi at Vertices and , guarding all vertices.
- Place a takahashi at all vertices, guarding all vertices.
5
1 3
4 5
1 5
2 3
1
0
2
5
7
17
10
6 10
1 8
2 7
5 6
3 8
3 4
7 10
4 9
2 8
1
0
3
8
15
32
68
110
196
266
325