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 JAVA):

Solution:
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }

    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        Set<Integer>[] nodes = new Set[N];
        for (int i = 0; i < N; i++) {
            nodes[i] = new HashSet<>();
        }
        for (int i = 0; i < N - 1; i++) {
            int a = scan.nextInt()-1;
            int b = scan.nextInt()-1;
            nodes[a].add(b);
            nodes[b].add(a);
        }
        int max_degree = 0;
        int root = 0;
        for (int i = 0; i < N; i++) {
            if (max_degree < nodes[i].size()) {
                max_degree = nodes[i].size();
                root = i;
            }
        }
        Map<Integer, List<Integer>> two_map = new HashMap<>();
        two_map.put(0, new ArrayList<>());
        two_map.put(1, new ArrayList<>());
        two_map.get(0).add(root);
        Set<Integer> unvisited = new HashSet<>();
        for (int i = 0; i < N; i++) {
            unvisited.add(i);
        }
        unvisited.remove(root);
        dfs(two_map, nodes, root, 0, unvisited);
        int mod_zero = two_map.get(0).size();
        int mod_one = two_map.get(1).size();

        Map<Integer, Deque<Integer>> candidates_map = new HashMap<>();
        candidates_map.put(0, new LinkedList<>());
        candidates_map.put(1, new LinkedList<>());
        candidates_map.put(2, new LinkedList<>());
        for (int i = 1; i <= N; i++) {
            candidates_map.get(i % 3).add(i);
        }
        Deque<Integer> zero_candidate = candidates_map.get(0);
        Deque<Integer> one_candidate = candidates_map.get(1);
        Deque<Integer> two_candidate = candidates_map.get(2);
        int[] ans = new int[N];
        Arrays.fill(ans, -1);
        if (N / 3 < mod_zero && N / 3 < mod_one) {
            for (int x : two_map.get(0)) {
                if (!one_candidate.isEmpty()) {
                    ans[x] = one_candidate.poll();
                    continue;
                }
                ans[x] = zero_candidate.poll();
            }
            for (int x : two_map.get(1)) {
                if (!two_candidate.isEmpty()) {
                    ans[x] = two_candidate.poll();
                    continue;
                }
                ans[x] = zero_candidate.poll();
            }
            print(N, ans);
            return;
        }
        if (mod_zero <= N / 3) {
            for (int x : two_map.get(0)) {
                 ans[x] = zero_candidate.poll();
            }
            for (int x : two_map.get(1)) {
                if (!zero_candidate.isEmpty()) {
                    ans[x] = zero_candidate.poll();
                    continue;
                }
                if (!one_candidate.isEmpty()) {
                    ans[x] = one_candidate.poll();
                    continue;
                }
                ans[x] = two_candidate.poll();
            }
            print(N, ans);
            return;
        }
        for (int x : two_map.get(1)) {
            ans[x] = zero_candidate.poll();
        }
        for (int x : two_map.get(0)) {
            if (!zero_candidate.isEmpty()) {
                ans[x] = zero_candidate.poll();
                continue;
            }
            if (!one_candidate.isEmpty()) {
                ans[x] = one_candidate.poll();
                continue;
            }
            ans[x] = two_candidate.poll();
        }
        print(N, ans);
    }
    private void print(int N, int[] ans) {
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < N; i++) {
            sb.append(ans[i]);
            sb.append(" ");
        }
        System.out.println(sb.substring(0, sb.length()-1));
    }
    private void dfs(Map<Integer, List<Integer>> map, Set<Integer>[] nodes, int current, int distance, Set<Integer> unvisited) {
        if (unvisited.isEmpty()) {
            return;
        }
        Set<Integer> child = nodes[current];
        for (int next : child) {
            if (!unvisited.contains(next)) {
                continue;
            }
            unvisited.remove(next);
            map.get((distance+1)%2).add(next);
            dfs(map, nodes, next, distance + 1, unvisited);
            unvisited.add(next);
        }
    }
}