Problem: We have a tree with N vertices. The vertices are numbered 1 to N, and the i-th edge connects Vertex a_i and Vertex b_i.

Takahashi loves the number 3. He is seeking a permutation p_1, p_2, \ldots , p_N of integers from 1 to N satisfying the following condition:

* For every pair of vertices (i, j), if the distance between Vertex i and Vertex j is 3, the sum or product of p_i and p_j is a multiple of 3.



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

Help Takahashi by finding a permutation that satisfies the condition.

Constraints

* 2\leq N\leq 2\times 10^5
* 1\leq a_i, b_i \leq N
* The given graph is a tree.

Input

Input is given from Standard Input in the following format:


N
a_1 b_1
a_2 b_2
\vdots
a_{N-1} b_{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.

Example

Input

5
1 2
1 3
3 4
3 5


Output

1 2 5 4 3

Solution (in PYTHON3):

Solution:
# 完全二部グラフで大丈夫なら全部大丈夫(最悪で大丈夫かどうか)
# 簡単のためN=3kとする(3の倍数以外でもほとんど同じなので)
# 0,1,2がk個ずつ

# 1-1,2-2間に辺があるとダメ(これだけを避ければよい)
#   1-2,1-0,2-1,2-0,0-0はOKなので

# 二部グラフで片側の頂点が2k以上(もう一方がk個以下)の場合
#   2k以上の方に1,2を割り当てて、反対側をすべて0にする

# 両方とも(k,2k)の場合
# 両方k以上なのでLを1、Rを2で埋めて残りを0で埋める


def main():
    from collections import deque
    from itertools import chain
    import sys
    input = sys.stdin.readline

    # INPUT
    N = int(input())

    graph = tuple(set() for _ in range(N))
    for _ in range(N - 1):
        a, b = (int(x) - 1 for x in input().split())
        graph[a].add(b)
        graph[b].add(a)

    # BFS
    dq = deque([0])
    parity = [-1] * N
    parity[0] = 0
    size_0 = 0
    while dq:
        v = dq.popleft()
        p = parity[v]
        if p == 0:
            size_0 += 1
        np = 1 ^ p
        for u in graph[v]:
            if ~parity[u]: continue
            parity[u] = np
            dq.append(u)

    # SOLVE
    k = N // 3  # 3の倍数の個数
    g1 = iter(range(1, N + 1, 3))  # rangeのままだとchain(g1,g2,g3)としたときg3が途中から始まらない
    g2 = iter(range(2, N + 1, 3))  # range != iteratorなので消費が共有されないため
    g3 = iter(range(3, N + 1, 3))
    if size_0 <= k:  # parity=0を3の倍数で埋め,残りを余った数で埋める
        g123 = chain(g1, g2, g3)
        ret = (next(g3) if p == 0 else next(g123) for p in parity)

    elif N - size_0 <= k:  # parity=1を3の倍数で埋め,残りを余った数で埋める
        g123 = chain(g1, g2, g3)
        ret = (next(g3) if p == 1 else next(g123) for p in parity)

    else:  # parity=0を(mod3=1)で,parity=1を(mod3=2)で埋め,残りを3の倍数で埋める
        g13 = chain(g1, g3)
        g23 = chain(g2, g3)
        ret = (next(g13) if p == 0 else next(g23) for p in parity)

    print(*ret)


if __name__ == '__main__':
    main()