#include<bits/stdc++.h>
using namespace std;
const int maxn = 300001;
int n;
struct info{
	int v, w;
};
vector < info > edge[maxn];
int color[maxn];
void dfs(int now, int dis){
	if(color[now])return;
	color[now] = (dis & 1) + 1;
	for(auto &v : edge[now]){
		dfs(v.v, dis + v.w);
	}
}
int main(){
	cin >> n;
	for(int i = 1, a, b, w;i < n;++i){
            cin >> a >> b >> w;
		edge[a].push_back({b, w});
		edge[b].push_back({a, w});
	}
	dfs(1, 0);
	for(int i = 1;i <= n;++i)cout << color[i] - 1 << '\n';
}
