404692: GYM101611 C Carpet
Description
All cinema stars of Treeland are gathering in its capital to take part in the cinema academy award ceremony. This time organizers decided to prepare something very new for the welcoming part. Their idea is to replace old-fashioned red carpet with a one having a map of Treeland depicted on it.
Treeland consists of n cities connected with n - 1 bidirectional roads in such a way that it is possible to get from any city to any other city. Let us represent the carpet as a rectangular grid of 1 000 000 × 20 unit square cells. Cities should be painted in centers of some cells in such a way that no two cities occupy the same cell. After that roads are painted as segments connecting corresponding cell centers.
To make the carpet beautiful, it was decided to place cities in such a way that no two segments corresponding to roads intersect. This means that no two segments have common points different from their common endpoints.
Some clever mathematician already proved that a solution exists, but unfortunately his proof doesn't provide a way to construct the answer, so this task was assigned to you.
InputThe first line of the input contains a single integer n (1 ≤ n ≤ 100 000) — the number of cities in Treeland.
Each of the next n - 1 lines contains a pair of integers ui and vi (1 ≤ ui, vi ≤ n, ui ≠ vi) — indices of a road that connects cities ui and vi. It is guaranteed that it is possible to get from any city to any other city.
OutputPrint n lines. The i-th of these lines should contain two integers xi and yi (1 ≤ xi ≤ 1 000 000, 1 ≤ yi ≤ 20) — the coordinates of the cell to place the i-th city.
ExamplesInput6Output
1 2
1 3
1 4
4 5
4 6
2 2Input
1 1
1 3
3 2
4 3
4 1
7Output
1 2
1 3
2 4
2 5
3 6
3 7
1 1Note
1 2
2 2
1 3
2 3
3 3
4 3
The picture below illustrates a possible solution for the first sample.