In a programming company, n n programmers are working. These programmers with numbers 1…
- User
In a programming company, n n programmers are working. These programmers with numbers 1 to n n are numbered. The management system of this company is in the form of a tree. That is, every programmer except programmer number 1 has a manager. Programmer manager i i with p i p i We show In fact, the structure of this company is like a rooted tree.
Nowruz is near and these programmers want to leave the company and go to Kodak city for a trip. When the programmer no i i can leave the company that p i p i He has also left the organization.
for every k k from 1 to n n Count how many subsets k k members of programmers can leave the company. Since the answer may be too large, take the remainder 1 0 9 + 7 10 9 Print +7.
input In the first line of input, integer and positive number n n stands for the number of programmers in the company. 2 ≤ n ≤ 10 , 000 2≤n≤10,000
In the second line of the input, n
1 n−1 integer p 2 , p 3 , … , p n , p 2 ,p 3 ,...,p n , comes 1 ≤ p i < i 1≤p i <i
output output n has n lines and in the line k k is the number of modes that k Calculate k people leave the company.
examples Sample entry 1 3 1 1 Plain text Sample output 1 1 2 1 Plain text Explanation of sample 1 Sample input 2 5 1 1 2 2 Plain text Sample output 2 1 2 3 3 1 write in c++
- Assistant