Problem: We have a tree with N vertices numbered 1 to N. The i-th edge in the tree connects Vertex u_i and Vertex v_i, and its length is w_i. Your objective is to paint each vertex in the tree white or black (it is fine to paint all vertices the same color) so that the following condition is satisfied:

* For any two vertices painted in the same color, the distance between them is an even number.



Find a coloring of the vertices that satisfies the condition and print it. It can be proved that at least one such coloring exists under the constraints of this problem.

Constraints

* All values in input are integers.
* 1 \leq N \leq 10^5
* 1 \leq u_i < v_i \leq N
* 1 \leq w_i \leq 10^9

Input

Input is given from Standard Input in the following format:


N
u_1 v_1 w_1
u_2 v_2 w_2
.
.
.
u_{N - 1} v_{N - 1} w_{N - 1}


Output

Print a coloring of the vertices that satisfies the condition, in N lines. The i-th line should contain `0` if Vertex i is painted white and `1` if it is painted black.

If there are multiple colorings that satisfy the condition, any of them will be accepted.

Examples

Input

3
1 2 2
2 3 1


Output

0
0
1


Input

5
2 5 2
2 3 10
1 3 8
3 4 2


Output

1
0
1
0
1

Solution (in JAVA):

Solution:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		SC sc = new SC(System.in);
		//重み付きUFっぽくねぇか
		int N=sc.nextInt();
		WUnionFindTree uft=new WUnionFindTree(N);
		for(int i=0; i<N-1; i++) {
			int u=sc.nextInt();
			int v=sc.nextInt();
			long w=sc.nextLong();
			uft.union(u,v,w);
		}
		int[] nurinuri=new int[N+1];
		nurinuri[1]=0;
		for(int i=2; i<=N; i++) {
			if(uft.diff(1,i)!=null && Math.abs((long) uft.diff(1, i))%2==0){
				nurinuri[i]=0;
			}
			else {
				nurinuri[i]=1;
			}
		}
		for(int i=1; i<=N; i++) {
			pl(nurinuri[i]);
		}
	}
	static class SC {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;
		public SC(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
		}
		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new UncheckedIOException(e);
			}
		}
	}
	public static void pl(Object o) {
		System.out.println(o);
	}
	public static void pl() {
		System.out.println();
	}
	public static void p(Object o) {
		System.out.print(o);
	}
	public static class WUnionFindTree{
		int[] par; // 親の番号
		long[] ws;  // 親との重みの差
		public WUnionFindTree(int n){
			par = new int[n+1];
			ws  = new long[n+1];
			for(int i = 0; i <= n; i++){ par[i] = -1; }
		}
		public int find(int x){
			if(par[x] < 0){
				return x;
			}else{
				final int parent = find(par[x]);
				ws[x] += ws[par[x]];
				return par[x] = parent;
			}
		}
		public long weight(int x){
			find(x);
			return ws[x];
		}
		public boolean union(int x, int y, long w){ // x <-(w)- y (x + w = y)
			w += weight(x);
			w -= weight(y);
			x = find(x); y = find(y);
			if(x != y){
				if(par[y] < par[x]) {
					int tmp = x; x = y; y = tmp; w = -w;
				}
				par[x] += par[y]; par[y] = x;
				ws[y] = w;
				return true;
			}else{
				return false;
			}
		}
		public boolean same(int x, int y){
			return find(x) == find(y);
		}
		public Long diff(int x, int y){ // y - x を求める. 比較不能ならnull.
			if(!same(x, y)){ return null; }
			return this.weight(y) - this.weight(x);
		}
		public int size(int x){
			return -par[find(x)];
		}
	}
}