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>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SZ(x) ((int)x.size())
#define FOR(i,a,b) for (int i=a;i<=b;++i)
#define FORD(i,a,b) for (int i=a;i>=b;--i)
using namespace std;
typedef long long LL;
typedef pair<int,int> pa;
typedef vector<int> vec;
void getint(int &v){
    char ch,fu=0;
    for(ch='*'; (ch<'0'||ch>'9')&&ch!='-'; ch=getchar());
    if(ch=='-') fu=1, ch=getchar();
    for(v=0; ch>='0'&&ch<='9'; ch=getchar()) v=v*10+ch-'0';
    if(fu) v=-v;
}
vec v[5];
bool u[600010];
int c[5],nedge,too[500010],ans[600010],hed[600010],nxt[500010],dep[600010],n,x,y;
void ae(int x,int y){
	nxt[++nedge]=hed[x];
	hed[x]=nedge;
	too[nedge]=y;
}
void dfs(int x,int l){
	dep[x]=dep[l]+1;
	for (int i=hed[x];i;i=nxt[i]){
		int y=too[i];
		if (y==l) continue;
		dfs(y,x);
	}
}
void R(){
	FOR(i,1,n) u[ans[i]]=1;
	int t=1;
	FOR(i,1,n)if (!ans[i]){
		while (u[t]) ++t;
		ans[i]=t;
		++t;
	}
}
int main(){
	cin>>n;
	FOR(i,2,n){
		getint(x),getint(y);
		ae(x,y),ae(y,x);
	}
	dfs(1,0);
	FOR(i,1,n) v[dep[i]%2].pb(i);
	FOR(i,1,n) c[i%3]++;
	if (c[2]>SZ(v[0])){
		FOR(i,0,SZ(v[0])-1){
			ans[v[0][i]]=i*3+3;
			u[i*3+3]=1;
		}
		R();
	}
	else if (c[1]>SZ(v[1])){
		FOR(i,0,SZ(v[1])-1){
			ans[v[1][i]]=i*3+3;
			u[i*3+3]=1;
		}
		R();
	}
	else{
		FOR(i,0,c[2]-1){
			ans[v[0][i]]=i*3+2;
			u[i*3+2]=1;
		}
		FOR(i,0,c[1]-1){
			ans[v[1][i]]=i*3+1;
			u[i*3+1]=1;
		}
		R();
	}
	FOR(i,1,n) printf("%d ",ans[i]);
	return 0;
}