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 LL long long

const int N = 2e5 + 5;
const int M = 2e5 + 5;

int n, cnt, first[N], dep[N] = { -1 },ans[N],cntt[2];

std::queue <int> q[3];

struct EDGE {
	int to, _next;
} e[M << 1];

void Add_Edge(int u, int v) {
	e[cnt].to = v;
	e[cnt]._next = first[u];
	first[u] = cnt++;
}

void dfs(int x, int p) {
	dep[x] = dep[p] + 1;
	for(int i = first[x], y = e[i].to; ~i; i = e[i]._next, y = e[i].to)
	if(y != p) dfs(y, x);
}

int main() {
	std::cin >> n;
	memset(first, -1, sizeof(first));
	for(int i = 1; i <= n - 1; ++i) {
		int u, v;
		std::cin >> u >> v;
		Add_Edge(u, v);
		Add_Edge(v, u);
	}
	dfs(1, 0);
	for(int i = 1; i <= n; ++i)
		q[i % 3].push(i),++cntt[dep[i]%2];
	if(std::min(cntt[0],cntt[1])<=n/3)
	{
		int k=cntt[0]>cntt[1];
		for(int i=1;i<=n;++i) if(dep[i]%2==k) {ans[i]=q[0].front();q[0].pop();continue;}
		for(int i=1;i<=n;++i)
			if(dep[i]%2!=k)
			{
				if(!q[0].empty()) {ans[i]=q[0].front();q[0].pop();continue;}
				if(!q[1].empty()) {ans[i]=q[1].front();q[1].pop();continue;}
				if(!q[2].empty()) {ans[i]=q[2].front();q[2].pop();continue;}
			}
	}
	else
		for(int i = 1; i <= n; ++i)
		{
			if(!q[dep[i]%2+1].empty()) ans[i]=q[dep[i]%2+1].front(),q[dep[i]%2+1].pop();
			else ans[i]=q[0].front(),q[0].pop();
		}
	for(int i = 1; i <= n; ++i) printf("%d ",ans[i]);
	return 0;
}

// ----------------------------
// by imzzy