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>
typedef int LL;
#define pb push_back
const LL maxn=1e6+9;
struct node{
	LL to,nxt;
}dis[maxn];
LL n,num;
LL head[maxn],p[maxn],dep[maxn];
std::vector<LL> V[3],a[3];
void Add(LL u,LL v){
	dis[++num]=(node){v,head[u]}; head[u]=num;
}
void Dfs(LL u,LL f){
	V[dep[u]].pb(u);
	for(LL i=head[u];i;i=dis[i].nxt){
		LL v(dis[i].to); if(v==f) continue;
		dep[v]=(dep[u]^1); Dfs(v,u); 
	}
}
int main(){
	scanf("%d",&n);
	for(LL i=1;i<n;++i){
		LL u,v; scanf("%d%d",&u,&v);
		Add(u,v); Add(v,u);
	}
	for(LL i=1;i<=n;++i){
		a[i%3].pb(i);
	}
	LL ret(n/3);
	Dfs(1,0);
	if(V[0].size()>V[1].size()) std::swap(V[0],V[1]);
	LL tot0(0),tot1(0),tot2(0);
	if(V[0].size()<=ret){
		for(LL i=0;i<V[0].size();++i){
			LL x(V[0][i]);
			p[x]=a[0][tot0++];
		}
		for(LL i=0;i<V[1].size();++i){
			LL x(V[1][i]);
            if(tot2<a[2].size()) p[x]=a[2][tot2++];
		    else if(tot0<a[0].size()) p[x]=a[0][tot0++];
		    else p[x]=a[1][tot1++];
		}
		for(LL i=1;i<=n;++i) printf("%d ",p[i]); puts("");
		return 0;
	}
	for(LL i=0;i<V[0].size();++i){
		LL x(V[0][i]);
		if(tot1<a[1].size()) p[x]=a[1][tot1++];
		else if(tot0<a[0].size()) p[x]=a[0][tot0++];
		else p[x]=a[2][tot2++];
	}
	for(LL i=0;i<V[1].size();++i){
		LL x(V[1][i]);
		if(tot2<a[2].size()) p[x]=a[2][tot2++];
		else if(tot0<a[0].size()) p[x]=a[0][tot0++];
		else p[x]=a[1][tot1++];
	}
	for(LL i=1;i<=n;++i) printf("%d ",p[i]);
	puts("");
	return 0;
}