#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
using namespace std;

int n;
vector<vector<P>> G;
vector<int> ans;

void dfs(int v, int p, int c) {
  ans[v]=c;
  for (auto nv : G[v]) {
    if (nv.first==p) continue;
    if (nv.second & 1) dfs(nv.first, v, 1-c);
    else dfs(nv.first, v, c);
  }
}

int main() {
  cin>>n;
  G.assign(n, vector<P>());
  rep(i, n-1) {
    int a,b,c; cin>>a>>b>>c;
    a--; b--;
    G[a].push_back(P(b, c));
    G[b].push_back(P(a, c));
  }
  ans.assign(n, 0);
  dfs(0, -1, 1);
  rep(i, n) cout<<ans[i]<<endl;
  return 0;
}
