#include<bits/stdc++.h>
using namespace std;
int n,t1,t2,t3;
bool color[100005],vis[100005];
vector<pair<int,bool> > a[100005];
void dfs(int x,bool c){
	if(vis[x]){
		return;
	}
	color[x]=c;
	vis[x]=1;
	for(int i=0;i<a[x].size();i++){
		if(a[x][i].second){
			dfs(a[x][i].first,!c);
		}else{
			dfs(a[x][i].first,c);
		}
	}
}
int main(){
	cin>>n;
	for(int i=1;i<n;i++){
		cin>>t1>>t2>>t3;
		if(t3%2==0){
			a[t1].push_back({t2,0});
			a[t2].push_back({t1,0});
		}else{
			a[t1].push_back({t2,1});
			a[t2].push_back({t1,1});
		}
	}
	dfs(1,0);
	for(int i=1;i<=n;i++){
		cout<<color[i]<<endl;
	}
	return 0;
} 