You are given a rooted tree with vertices. Vertex is the root.
For every non-leaf vertex , you may choose one linear ordering of the children of . The order is fixed before any ball is inserted and cannot be changed while the balls move.
Balls are inserted into the root one by one. Consider the -th ball that enters a vertex . If has children, the ball moves to the
-th child in the chosen order. A ball stops when it reaches a leaf.
Whenever a ball reaches a leaf , you gain points. The value may be negative.
For every , find the maximum total score obtainable after inserting balls into the root. The child orderings may be chosen differently for different values of .
Input
The input is given from Standard Input in the following format:
Each case is given in the following format:
For every , there is an edge between vertices and . The given graph is a tree rooted at vertex .
The values of non-leaf vertices do not affect the answer.
Output
For each test case, print integers on one line, separated by spaces.
must be the maximum total score obtainable after inserting balls into the root.
Constraints
- .
- .
- .
- ().
- ().
- The given edges form a tree.
- ().
- The sum of over all test cases does not exceed .
- The sum of over all test cases does not exceed .
Subtasks
Samples
For each value of , choose the child orderings and move every ball according to the rule. Selecting an ordering with the highest total score gives the printed values.