#include<bits/stdc++.h>
using namespace std;
int N;
int visit[100001];

struct st{
	int fin,cost;
};
vector<st> edge[100001];
queue<int> q;
bool color[100001];
int main(){
	cin>>N;
	int u,v,w;
	for(int i=1;i<N;i++){
		cin>>u>>v>>w;
		edge[u].push_back({v,w}); edge[v].push_back({u,w});	
	}
	visit[edge[1][0].fin]=1; visit[1]=1;
	if(edge[1][0].cost%2) color[edge[1][0].fin]=1;
	q.push(1); q.push(edge[1][0].fin);
	while(!q.empty()){
		int imsi=q.front(); q.pop();
		visit[imsi]=1;
		for(int i=0;i<edge[imsi].size();i++){
			st &now=edge[imsi][i];
			if(visit[now.fin]==0){
				if(now.cost%2) color[now.fin]=!color[imsi];
				q.push(now.fin);
			}
		}
	}
	for(int i=1;i<=N;i++) cout<<color[i]<<endl;
}