#include <bits/stdc++.h>
using namespace std;
const long long max_n=100010;
long long n,c[max_n];
vector<pair<long long,long long> > t[max_n];
void dfs(long long b,long long previous=-1){
	for (auto it: t[b]){
		long long a=it.first;
		long long d=it.second%2;
		if (a!=previous){
			c[a]=c[b]^d;
			dfs(a,b);
		}
	}
}
int main()
{
	cin>>n;
	for (int i=0;i<n-1;++i){
		long long a,b,d;
		cin>>a>>b>>d;
		t[a].push_back({b,d});
		t[b].push_back({a,d}); 
	}
	dfs(1);
	for (int i=1;i<=n;++i)
	    cout<<c[i]<<endl;
}