Problem: You are given a tree with n nodes. You have to write non-negative integers on its edges so that the following condition would be satisfied:

For every two nodes i, j, look at the path between them and count the sum of numbers on the edges of this path. Write all obtained sums on the blackboard. Then every integer from 1 to ⌊ (2n^2)/(9) ⌋ has to be written on the blackboard at least once. 

It is guaranteed that such an arrangement exists.

Input

The first line contains a single integer n (1 ≤ n ≤ 1000) — the number of nodes.

Each of the next n-1 lines contains two integers u and v (1 ≤ u, v ≤ n, u ≠ v), meaning that there is an edge between nodes u and v. It is guaranteed that these edges form a tree.

Output

Output n-1 lines, each of form u v x (0 ≤ x ≤ 10^6), which will mean that you wrote number x on the edge between u, v. 

Set of edges (u, v) has to coincide with the set of edges of the input graph, but you can output edges in any order. You can also output ends of edges in an order different from the order in input.

Examples

Input


3
2 3
2 1


Output


3 2 1
1 2 2


Input


4
2 4
2 3
2 1


Output


4 2 1
3 2 2
1 2 3


Input


5
1 2
1 3
1 4
2 5


Output


2 1 1
5 2 1
3 1 3
4 1 6

Note

In the first example, distance between nodes 1 and 2 is equal to 2, between nodes 2 and 3 to 1, between 1 and 3 to 3.

In the third example, numbers from 1 to 9 (inclusive) will be written on the blackboard, while we need just from 1 to 5 to pass the test.

Solution (in JAVA):

Solution:
import java.io.*;
import java.util.*;

public class CF1206F extends PrintWriter {
	CF1206F() { super(System.out); }
	Scanner sc = new Scanner(System.in);
	public static void main(String[] $) {
		CF1206F o = new CF1206F(); o.main(); o.flush();
	}

	int[] next, jj; int l_ = 1;
	int link(int l, int j) { next[l_] = l; jj[l_] = j; return l_++; }
	int[] ao; int n;
	int[] cc;
	void init() {
		int m = n - 1;
		next = new int[1 + m * 2];
		jj = new int[1 + m * 2];
		ao = new int[n];
		cc = new int[n];
	}
	int n_, i_, j_;
	int dfs(int p, int i) {
		int k = 1;
		for (int l = ao[i]; l != 0; l = next[l]) {
			int j = jj[l];
			if (j != p)
				k += dfs(i, j);
		}
		int k_ = Math.min(k, n - k);
		if (n_ < k_) {
			n_ = k_;
			if (k <= n - k) {
				i_ = i;
				j_ = p;
			} else {
				i_ = p;
				j_ = i;
			}
		}
		cc[i] = k;
		return k;
	}
	int a, b;
	void dfs_(int p, int i, int c, boolean print) {
		if (print) {
			a += b;
			println((p + 1) + " " + (i + 1) + " " + (a - c));
			c = a;
		}
		for (int l = ao[i]; l != 0; l = next[l]) {
			int j = jj[l];
			if (j != p)
				dfs_(i, j, c, true);
		}
	}
	void main() {
		n = sc.nextInt();
		if (n == 1)
			return;
		init();
		for (int h = 0; h < n - 1; h++) {
			int i = sc.nextInt() - 1;
			int j = sc.nextInt() - 1;
			ao[i] = link(ao[i], j);
			ao[j] = link(ao[j], i);
		}
		dfs(-1, 0);
		if (n_ * 3 >= n) {
			b = 1;
			a = 0;
			dfs_(i_, j_, 0, false);
			b = n - n_;
			a = 0;
			dfs_(j_, i_, 0, true);
		} else {
			int s = j_;
			dfs(-1, s);
			Integer[] tt = new Integer[n];
			int cnt = 0;
			for (int l = ao[s]; l != 0; l = next[l])
				tt[cnt++] = jj[l];
			Arrays.sort(tt, 0, cnt, (i, j) -> cc[i] - cc[j]);
			n_ = 1;
			b = 1;
			a = 0;
			boolean changed = false;
			for (int h = 0; h < cnt; h++) {
				int j = tt[h];
				n_ += cc[j];
				dfs_(s, j, 0, true);
				if (!changed && n_ * 3 >= n) {
					changed = true;
					b = n_;
					a = 0;
				}
			}
		}
	}
}