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
#include <bits/stdc++.h>
using namespace std;

int N;
vector<vector<int>> graph(222222);
vector<int> color(222222,-1);
vector<int> ans(222222,0);

void DFS(int f,int t){
	if(f==-1)color[t]=0;
	for(auto x:graph[t]){
		if(color[x]==-1){
			color[x]=(color[t]+1)%2;
			DFS(t,x);
		}
	}
}

int main(){
	cin >> N;
	for(int i=0;i<N-1;i++){
		int a,b;
		cin >> a >> b;
		a--;
		b--;
		graph[a].push_back(b);
		graph[b].push_back(a);
	}
	
	DFS(-1,0);
	
	int c=accumulate(color.begin(),color.begin()+N,0);
	
	if(c<=N/3){
		int used3=0;
		int used12=0;
		for(int i=0;i<N;i++){
			if(color[i]==1)ans[i]=3*(++used3);
		}
		for(int i=0;i<N;i++){
			if(ans[i]==0){
				if(used3<N/3)ans[i]=3*(++used3);
				else{
					ans[i]=3*(used12/2)+((used12)%2)+1;
					used12++;
				}
			}
		}
	}else if((N-c)<=N/3){
		int used3=0;
		int used12=0;
		for(int i=0;i<N;i++){
			if(color[i]==0)ans[i]=3*(++used3);
		}
		for(int i=0;i<N;i++){
			if(ans[i]==0){
				if(used3<N/3)ans[i]=3*(++used3);
				else{
					ans[i]=3*(used12/2)+((used12)%2)+1;
					used12++;
				}
			}
		}
	}else{
		int used1=0;
		int used2=0;
		int used3=0;
		for(int i=0;i<N;i++){
			if(color[i]==0 && used1<(N+2)/3)ans[i]=1+3*(used1++);
			else if(color[i]==1 && used2<(N+1)/3)ans[i]=2+3*(used2++);
			else ans[i]=3*(++used3);
		}
	}
	
	for(int i=0;i<N;i++)printf("%d%c",ans[i],((i<N-1)?(' '):('\n')));
	return 0;
}