#HITACHI2020C. ThREE

ThREE

Score : 600600 points

Problem Statement

We have a tree with NN vertices. The vertices are numbered 11 to NN, and the ii-th edge connects Vertex aia_i and Vertex bib_i.

Takahashi loves the number 33. He is seeking a permutation p1,p2,,pNp_1, p_2, \ldots , p_N of integers from 11 to NN satisfying the following condition:

  • For every pair of vertices (i,j)(i, j), if the distance between Vertex ii and Vertex jj is 33, the sum or product of pip_i and pjp_j is a multiple of 33.

Here the distance between Vertex ii and Vertex jj is the number of edges contained in the shortest path from Vertex ii to Vertex jj.

Help Takahashi by finding a permutation that satisfies the condition.

Constraints

  • 2N2×1052\leq N\leq 2\times 10^5
  • 1ai,biN1\leq a_i, b_i \leq N
  • The given graph is a tree.

Input

Input is given from Standard Input in the following format:

NN

a1a_1 b1b_1

a2a_2 b2b_2

\vdots

aN1a_{N-1} bN1b_{N-1}

Output

If no permutation satisfies the condition, print -1.

Otherwise, print a permutation satisfying the condition, with space in between. If there are multiple solutions, you can print any of them.

5
1 2
1 3
3 4
3 5
1 2 5 4 3

The distance between two vertices is 33 for the two pairs (2,4)(2, 4) and (2,5)(2, 5).

  • p2+p4=6p_2 + p_4 = 6
  • p2×p5=6p_2\times p_5 = 6

Thus, this permutation satisfies the condition.