#include<bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;

int color[N] ;
vector<pair<int ,int > > v[N];


void dfs(int i , int col , int par = -1) {
	
	for(auto j : v[i]) {
		int node = j.first , c = j.second;
		if(node == par) continue;
		if(c % 2 == 0) color[node] = col;
		else color[node] = col^1;
		dfs(node ,color[node] , i);
	}
	
}
		


int main() {
	int n ; cin >> n;
	for(int i = 0 ;i < n - 1; i ++) {
		int x , y, w ; cin >> x >> y >> w;
		v[x].push_back({y , w});
		v[y].push_back({x , w});
	}
	
	dfs(1 , 0);
	for(int i = 1; i <= n ; i ++) cout << color[i] << endl;
}
	
