#include<bits/stdc++.h>
using namespace std;
int color[100010];
int seen[100010];
vector<vector<pair<int,int > > >G(100010);
void dfs(int v,int p,int c){
  color[v]=c;
  seen[v]=1;
    for(auto e:G[v]){
      if(seen[e.first])continue;
        if(e.second%2)dfs(e.first,v,1-c);
        else dfs(e.first,v,c);
    }
}
int main(){
    int n;cin>>n;
    for(int i=0;i<n;i++){
        int u,v,w;cin>>u>>v>>w;
        G[u].push_back({v,w});
        G[v].push_back({u,w});
    }
  seen[1]=1;
    dfs(1,0,0);
    for(int i=1;i<=n;i++){
        cout<<color[i]<<endl;
    }
}