'use strict'

class Node {
  constructor(){
    this.value = 0;
    this.parent = null;
    this.childNodes = [];
  };
  top(){
    return this.parent==null ? this : this.parent.top();
  }
  propValue(value){
    this.value += value;
    for(let i=0;i<this.childNodes.length;i++){
      this.childNodes[i].propValue(value);
    }
  }
  addChild(childNode, value){
    if(this.top() === childNode.top()){
      return;
    }
    this.childNodes.push(childNode);
    childNode.propValue(this.value+value);
    childNode.parent = this;
  }
}


function Main(input) {
  input = input.split('\n');
  let N = parseInt(input.shift());
  let array = input.map(str => str.split(/\s/).map(a => a-0));
  let resultArray=[];
  let count = 0;
  let nodes = new Array(N+1)
  for(let i=0;i<N+1;i++){
    nodes[i] = new Node();
  }
  for(let i=0;i<array.length;i++){
    if(array[i][0] < array[i][1]){
      nodes[array[i][0]].addChild(nodes[array[i][1]], array[i][2]);
    } else {
      nodes[array[i][1]].addChild(nodes[array[i][0]], array[i][2]);
    }
  }
  for(let i=1;i<N+1;i++){
    console.log((nodes[i].value%2).toString())
  }
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
