#include "bits/stdc++.h"
using namespace std;

struct root {
	int to;
	int cost;
};

int N;
static int ANS[100000];
vector<root> V[100000];

void DFS(int x, int y, int cost) {
	ANS[x] = cost;
	for (root z : V[x]) {
		if (z.to != y) {
			DFS(z.to, x, cost + z.cost);
		}
	}
}

int main() {
	cin >> N;
	for (int i = 0; i < N - 1; i++) {
		int u, v, w;
		cin >> u >> v >> w;
		u--, v--, w = w % 2;
		V[u].push_back({ v, w });
		V[v].push_back({ u, w });
	}
	DFS(0, -1, 0);
	for (int i = 0; i < N; i++) {
		cout << ANS[i] % 2 << endl;
	}
}