atcoder#ABC269H. [ABC269Ex] Antichain
[ABC269Ex] Antichain
Score : points
Problem Statement
We have a rooted tree with vertices numbered to . Vertex is the root, and the parent of vertex is vertex .
A non-empty subset of the vertex set of is said to be a good vertex set when it satisfies the following condition.
- For every pair of different vertices in , the following holds: is not an ancestor of .
For each , find the number, modulo , of good vertex sets with exactly vertices.
Constraints
- All values in the input are integers.
Input
The input is given from Standard Input in the following format:
Output
Print lines. The -th line should contain the answer for .
4
1 2 1
4
2
0
0
For each , the good vertex sets of size are listed below.
- : $\lbrace 1 \rbrace, \lbrace 2 \rbrace, \lbrace 3 \rbrace, \lbrace 4 \rbrace$.
- : .
- : There is none.
6
1 1 2 2 5
6
6
2
0
0
0
6
1 1 1 1 1
6
10
10
5
1
0
10
1 2 1 2 1 1 2 6 9
10
30
47
38
16
3
0
0
0
0