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

vector<vector<pair<int, int>>> G;
vector<int> A;

void dfs(int now, int pre, int clr) {
  A.at(now) = clr;
  for (auto g : G.at(now))
    if (g.first != pre) dfs(g.first, now, clr^(g.second & 1));
}

int main() {
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  G.resize(N + 1), A.resize(N + 1);
  for (int i = 1, u, v, w; i < N && cin >> u >> v >> w; i++)
    G.at(u).emplace_back(v, w), G.at(v).emplace_back(u, w);

  dfs(1, 0, 0);

  for (int i = 1; i <= N; i++) cout << A.at(i) << "\n";
}