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:
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define For(i,a,b) for(register int i=(a);i<=(b);++i)
#define Rep(i,a,b) for(register int i=(a);i>=(b);--i)
#define int long long
using namespace std;
inline int read()
{
    char c=getchar();int x=0;bool f=0;
    for(;!isdigit(c);c=getchar())f^=!(c^45);
    for(;isdigit(c);c=getchar())x=(x<<1)+(x<<3)+(c^48);
    if(f)x=-x;return x;
}
#define maxn 1000005
int n;
struct edge{
	int to,nxt;
}e[maxn<<1];
int tot,head[maxn];
inline void adde(int u,int v){
	e[++tot]=(edge){v,head[u]};
	head[u]=tot;
}
stack<int>s1,s2;
bool d[maxn],vis[maxn];
int res[maxn];
void dfs(int u,int pa)
{
	d[u]=d[pa]^1;
	(d[u]?s1:s2).push(u);
	for(int i=head[u];i;i=e[i].nxt)
		if(e[i].to!=pa)dfs(e[i].to,u);
}
signed main()
{
	n=read();
	For(i,2,n){
		int u=read(),v=read();
		adde(u,v);adde(v,u);
	}dfs(1,0);
	if(s1.size()>s2.size())swap(s1,s2);
	int c1=(n+2)/3,c2=(n+1)/3,c3=n/3;
	if(s1.size()<=c3){
		int x=0;
		while(!s1.empty()){
			x+=3;res[s1.top()]=x;
			s1.pop();vis[x]=1;
		}x=1;
		For(i,1,n)
			if(!res[i]){
				while(vis[x])x++;
				res[i]=x;x++;
			}
	}else{
		int x=-2;
		while(!s1.empty()){
			x+=3;res[s1.top()]=x;
			s1.pop();
		}
		x=-1;
		while(!s2.empty()){
			x+=3;res[s2.top()]=x;
			s2.pop();
		}
		x=0;
		For(i,1,n)
			if(res[i]>n)x+=3,res[i]=x;
	}
	For(i,1,n)cout<<res[i]<<' ';puts("");
    return 0;
}