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<bits/stdc++.h>
using namespace std;
int main(){
  long N;cin>>N;
  vector<vector<long>>A(N);
  for(long i=0;i<N;i++){
    long a,b;cin>>a>>b;
    A[a-1].push_back(b-1);
    A[b-1].push_back(a-1);
  }
  vector<long>D(N,-1);D[0]=0;
  queue<long>q;q.push(0);
  while(q.size()){
    long f=q.front();q.pop();
    for(long n:A[f])if(D[n]==-1){
      D[n]=D[f]+1;q.push(n);
    }
  }
  long o=0,e=0;
  for(long x:D)x%2?o++:e++;
  vector<long>P(N);
  long x=1,y=2,z=3;
  if(o<(N+1)/3){
    for(long i=0;i<N;i++){
      if(D[i]%2){P[i]=z;z+=3;}
      else{
        if(x<=N){P[i]=x;x+=3;}
        else if(y<=N){P[i]=y;y+=3;}
        else {P[i]=z;z+=3;}
      }
    }
  }
  else if(e<(N+2)/3){
    for(long i=0;i<N;i++){
      if(D[i]%2==0){P[i]=z;z+=3;}
      else{
        if(x<=N){P[i]=x;x+=3;}
        else if(y<=N){P[i]=y;y+=3;}
        else {P[i]=z;z+=3;}
      }
    }
  }
  else{
    for(long i=0;i<N;i++){
      if(D[i]%2){
        if(y<=N){P[i]=y;y+=3;}
        else {P[i]=z;z+=3;}
      }
      else{
        if(x<=N){P[i]=x;x+=3;}
        else {P[i]=z;z+=3;}
      }
    }
  }
  for(long p:P)cout<<p<<" ";
  /*
  距離の偶奇の個数で場合分け
  : 偶数に1,奇数に2を振ってあとは3
  偶数が異様に多い時:
    1と3を全部使い切ってしまって2しか埋められなくなる
    [偶数の個数>1の個数+3の個数]
    1の個数=(N+2)//3
    2の個数=(N+1)//3
    3の個数=N//3
    偶数>(N+2)//3+N//3=N-(N+1)//3
    
    奇数=N-偶数<(N+1)//3
    
    
    この時, 奇数に全部3を埋めちゃえばいい
    
    こうなるのは...?
    奇数が, 3の個数以下
  奇数が異様に多い時:
  2,3
  [奇数の個数>2,3]
  偶数<(N+2)//3
  偶数に全部
  */
}


/*


*/