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("trapv")
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
using namespace std;
using ll = long long;
using vi = vector<ll>;
using pi = pair<ll, ll>;
const int maxn = 3e5 + 33, mod = 1e9 + 7;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define left dsafjalsjfsk
int n;
vi g[maxn], lst[2];
int  col[maxn];
void dfs(int v = 1, int p = 1, int h = 0) {
	lst[h&1].pb(v);
	for(auto i : g[v]) {
		if(i!=p) dfs(i, v, h^1);
	}
}
set<int> left;
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n;
	for(int f, t, i = 1; i < n; i++) {
		cin >> f >> t;
		g[f].pb(t);
		g[t].pb(f);
	}
	for(int i = 1; i <= n; i++) left.insert(i);
	dfs();
	if(lst[0].size() > lst[1].size()) swap(lst[0], lst[1]);
	if(lst[0].size() <= n/3) {
		int k = 3;
		for(auto i : lst[0]) col[i] = k, left.erase(k), k+=3;
	} else {
		int k = 3;
		while(k <= n) {
			if(lst[0].size()>lst[1].size()) col[lst[0].back()] = k, lst[0].pop_back();
			else col[lst[1].back()] = k, lst[1].pop_back();
			left.erase(k), k += 3;
		}
		if(lst[0].size() > lst[1].size()) swap(lst[0], lst[1]);
		k = 2;
		while(k <= n) {
			col[lst[0].back()] = k;
			lst[0].pop_back();
			left.erase(k), k += 3;
		}
		k = 1;
		while(k <= n) {
			col[lst[1].back()] = k;
			lst[1].pop_back();
			left.erase(k), k += 3;
		}
	}
	for(int i = 1; i <= n; i++) {
		if(!col[i]) col[i] = *left.begin(), left.erase(left.begin());
		cout << col[i] << " " ;
	}
}