Carol is going to a California internship this summer, so she needs to be prepared to travel. She asked Cactus for help, but the only thing she received was a very bad map. The map lists the edges that connect the cities of North America. However, they are not labelled by name. Carol knows that to read the map properly, she must assign a unique label to each node, an integer from to . However, Carol knows that for every subtree in the tree, the difference between the maximum label and the minimum label is as small as possible. Count the number of labellings of the tree which satisfy this condition, mod .
Constraints
Input Specification
The first line will contain , the number of cities.
The next lines will each contain an integer , the parent of the node.
The root of the tree is .
Output Specification
Output a single integer, the answer to the problem mod .
Sample Input
10
0
0
2
0
0
1
2
7
4
Sample Output
5760
Comments