Cave
Memory limit: 256 MB
Byteasar has discovered a cave.
It appears that the cave contains chambers connected with passages in such a way that
there exists a single way of getting from any chamber to any other chamber.
The cave should now be examined more thoroughly, so Byteasar has asked his friends for help.
They have all arrived at the cave and they are willing to divide themselves into groups.
Each group should examine the same number of chambers, and each chamber should be examined by exactly one group.
Additionally, for the groups not to interfere with each others' work, the members of each group
should be able to move between the assigned chambers without passing through chambers
assigned to other groups.
How many groups can the explorers be divided into?
Input
The first line of the input contains one integer () denoting the number of chambers in the cave.
The chambers are numbered through .
The following lines describe connections between the chambers.
The -th of these lines contains an integer () which
represents a passage connecting chambers number and .
Output
Your program should output a single line containing all integers , such that
the chambers can be divided into disjoint sets of equal size, and one
can move between any two chambers belonging to the same set passing only through chambers from this set.
The numbers should be written in an ascending order and separated with single spaces.
Example
For the input data:
6
1
2
3
3
5
the correct result is:
1 3 6
Task author: Jakub Lacki.