#include <bits/stdc++.h>

using namespace std;
#define MAXN 100002

vector <pair <int,int> > adj[MAXN];
bool colors[MAXN];

void dfs(int node, int parent = - 1, long long int w = 0){
  colors[node] = w % 2;
  for(pair <int,int> &i : adj[node]){
    if(i.first == parent)continue;
    dfs(i.first,node, w + i.second);
  }
}
int main(){
  int N;
  cin >> N;
  for(int i = 1, a, b, w; i < N; i++){
    	cin >> a >> b >> w;
    	adj[a].push_back({b,w});
    	adj[b].push_back({a,w});
  }
  dfs(1);
  for(int i = 1; i <= N; i++){
    cout << colors[i] << '\n';
  }
}