#include <bits/stdc++.h>
using namespace std;
using PP = pair<int, int>;

int n;
vector<PP> G[100000];
bool col[100000];

void rec(int from, int prev, bool c) {
  col[from] = c;
  for (PP e : G[from]) {
    int to = e.first;
    int dist = e.second;
    if (to == prev) continue;
    rec(to, from, dist % 2 == 0 ? c : !c);
  }
}

int main() {
  cin >> n;
  for (int i = 1; i < n; ++i) {
    int a, b, c;
    cin >> a >> b >> c;
    --a; --b;
    G[a].push_back(PP(b, c));
    G[b].push_back(PP(a, c));
  }
  
  rec(0, -1, 0);
  
  for (int i = 0; i < n; ++i) {
    cout << col[i] << endl;
  }
}
