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

Solution:
#include <stdio.h>
#include <queue>
#include <vector>
using namespace std;
typedef long long ll;

int main(void) {
  ll i, j, k, n, a, b, now, cnt = 0, ans[3] = {0, 0, 1};
  scanf("%lld", &n);
  vector<ll> vec[n];
  for(i = 0; i < n - 1; ++i) {
    scanf("%lld%lld", &a, &b);
    vec[--a].push_back(--b);
    vec[b].push_back(a);
  }
  bool d[n], flg[n];
  for(i = 0; i < n; ++i) flg[i] = true;
  flg[0] = false;
  queue<ll> q;
  d[0] = true;
  q.push(0);
  while(q.size()) {
    now = q.front(), q.pop();
    for(i = 0; i < vec[now].size(); ++i) if(flg[vec[now][i]]) {
      flg[vec[now][i]] = false;
      q.push(vec[now][i]);
      d[vec[now][i]] = !d[now];
    }
  }
  for(i = 0; i < n; ++i) cnt += d[i] ? 1 : 0;
  if(cnt > n - cnt) {
    for(i = 0; i < n; ++i) d[i] = !d[i];
    cnt = n - cnt;
  }
  if(cnt > n / 3) {
    for(i = 0; i < n; ++i) {
      if(d[i]) {
        if(ans[0] < (n + 2) / 3) printf("%lld ", ans[0] * 3 + 1), ans[0]++;
        else printf("%lld ", ans[2] * 3), ans[2]++;
      } else {
        if(ans[1] < (n + 1) / 3) printf("%lld ", ans[1] * 3 + 2), ans[1]++;
        else printf("%lld ", ans[2] * 3), ans[2]++;
      }
    }
  } else {
    for(i = 0; i < n; ++i) {
      if(d[i]) {
        printf("%lld ", ans[2] * 3), ans[2]++;
      } else {
        if(ans[0] < (n + 2) / 3) printf("%lld ", ans[0] * 3 + 1), ans[0]++;
        else if(ans[1] < (n + 1) / 3) printf("%lld ", ans[1] * 3 + 2), ans[1]++;
        else printf("%lld ", ans[2] * 3), ans[2]++;
      }
    }
  }
  return 0;
}