'use strict'

/////////////////////////////////////
//コピペスペース//////////////////////

//定数
const INF  =  900719925474099 // Math.floor(Number.MAX_SAFE_INTEGER / 10);

//スペース区切りの数字列を数字の配列にして返す
function mapint(line){return line.split(' ').map((v)=>parseInt(v));}

function lower_bound(d,a,b,e){
    for(var c;1<b-a;)
        d[c=0|(a+b)/2]<e ? a=c : b=c;
    return d[a]<e?b:a
};

const MOD = 1000000007;

let par;
 
function root(x){
    if(par[x]==x) return x;
    return par[x] = root(par[x]);
}
function unite(x,y){
    let rx = root(x);
    let ry = root(y);
    //console.log('unite',x,y,rx,ry)
    if(rx==ry) return;
    par[rx] = ry;
}
function same(x,y){
    let rx = root(x);
    let ry = root(y);
    return rx == ry;
}
//コピペスペース//////////////////////
/////////////////////////////////////

function Main(input){
	let temp = input.trim().split('\n');
	let n = parseInt(temp[0]);

	let u = new Array(n-1);
	let v = new Array(n-1);
	let w = new Array(n-1);

	par = new Array(n+1);
	for(let i=0;i<=n;i++){
		par[i] = i;
	}
	for(let i=1;i<n;i++){
		let tt = mapint(temp[i]);
		u[i-1] = tt[0];
		v[i-1] = tt[1];
		w[i-1] = tt[2];

		if((w[i-1]%2)==0){
			unite(u[i-1],v[i-1]);
			//console.log('unite,odd');
		}else{
			if(!same(u[i-1],1)){
				unite(v[i-1],1);
				//console.log('unite,odd');
			}
		}
	}
	let ans = new Array(n);
	for(let i=1;i<=n;i++){
		if(same(1,par[i])){
			ans[i-1] = 0;
		}else{
			ans[i-1] = 1;
		}
	}

	console.log(ans.join('\n'));

}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));
