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<cstdio>
#include<vector>
#define For(i,A,B) for(i=(A);i<=(B);++i)
using namespace std;
const int N=200050;
int G[N],to[N<<1],nxt[N<<1],sz,dep[N],cnt[2],p=-1,tot[3],n,s[N];
inline int newnum(int x){
    if(tot[x]){
        --tot[x];
        return x?tot[x]*3+x:tot[x]*3+3;
    }else return tot[0]--*3;
}
inline int newnum(){
    if(tot[1])return newnum(1);
    else return newnum(2);
}
inline void adde(int u,int v){
    to[++sz]=v;nxt[sz]=G[u];G[u]=sz;
    to[++sz]=u;nxt[sz]=G[v];G[v]=sz;
}
void dfs(int u,int fa,int d){
    int i,v;
    ++cnt[dep[u]=d];
    for(i=G[u];i;i=nxt[i])if((v=to[i])!=fa)dfs(v,u,d^1);
}
void Dfs(int u,int fa){
    int i,v;
    //printf("%d:%d:%d %d %d\n",u,dep[u],tot[0],tot[1],tot[2]);
    if(dep[u]==p)s[u]=newnum(0);
    else if(p==-1)s[u]=newnum(dep[u]+1);
    else s[u]=newnum();
    for(i=G[u];i;i=nxt[i])if((v=to[i])!=fa)Dfs(v,u);
}
int main(){
    int i,u,v;
    scanf("%d",&n);
    For(i,2,n){
        scanf("%d%d",&u,&v);
        adde(u,v);
    }
    dfs(1,0,0);
    tot[0]=n/3;tot[1]=(n+2)/3;tot[2]=(n+1)/3;
    if(cnt[0]<=n/3)p=0;
    else if(cnt[1]<=n/3)p=1;
    Dfs(1,0);
    For(i,1,n)printf("%d ",s[i]);
    puts("");
    return 0;
}