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 <iostream>
#include <vector>
#include <bitset>
#include <utility>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
 
using namespace std;
typedef long long ll;
 
int main(){
  int N;
  cin >> N;

  vector<vector<int> > t(N);

  int a,b;
  for(int i=0;i<N-1;i++){
    cin >> a >> b;
    t[a-1].push_back(b-1);
    t[b-1].push_back(a-1);
  }

  vector<int> P(N,-1);
  int f=0;
  P[0]=1;
  int cur=0;
  deque<int> s;
  s.push_back(0);
  while(!s.empty()){
    cur=s.back();
    s.pop_back();
    for(auto ti:t[cur]){
      if(P[ti]==-1){
	P[ti]=P[cur]+1;
	s.push_back(ti);
      }
    }
  }

  int n0=0,n1=0;
  for(auto pi:P){
    if(pi%2==0) n0++; else n1++;
  }

  int m0=0,m1=0,m2=0;
  if(n0<=N/3 || n1<=N/3){
    int r;
    if(n0<=N/3) r=0; else r=1;
    for(int i=0;i<N;i++){
      if(P[i]%2==r) {cout << 3*m0+3; m0++;}
      else{
	if(3*m1+1<=N) {cout << 3*m1+1; m1++;}
	else if(3*m2+2<=N) {cout << 3*m2+2; m2++;}
	else {cout << 3*m0+3; m0++;}
      }
      cout << " ";
    }
  }else{
    for(int i=0;i<N;i++){
      int r=P[i]%2;
      if(r==0){
	if(3*m1+1<=N) {cout << 3*m1+1; m1++;}
	else {cout << 3*m0+3; m0++;}
      }else{
	if(3*m2+2<=N) {cout << 3*m2+2; m2++;}
	else {cout << 3*m0+3; m0++;}
      }      
      cout << " ";
    }
  }
  cout << endl;    
  
  return 0;
}