Main(myin());
function myin(){return require("fs").readFileSync("/dev/stdin", "utf8").trim();}
function myout(t){console.log(t);}//standard output
function myerr(t){console.error(t);}//standard error
//[no]param
//不明値:何もしない  1:数値へ変換  2:半角SPで分割  3:改行で分割  4:半角SPで分割し、数値配列へ
//5:改行で分割し、数値配列へ  6:1文字に分割  7:1文字に分割し、数値配列へ
//8:半角SPで結合　9:改行で結合　0:文字なしで結合
function myconv(i,no){switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 3:return i.split("\n");case 4:return i.split(" ").map((a)=>Number(a));case 5:return i.split("\n").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}
function Main(input) {
  input = myconv(input,3);
  var N = myconv(input[0],1);
  input.shift();
  var list = new Array(N);
  for(var i = 0; i < N; i++){
    list[i] = temple();
  }
  for(var i = 0; i < N-1; i++){
    var tmp = myconv(input[i],4);
    list[tmp[0]-1]["children"][tmp[1]-1] = tmp[2];
    list[tmp[1]-1]["children"][tmp[0]-1] = tmp[2];
  }
  dfs(0,null,null);
  function dfs(ima,oya,kyori){
  if(oya != null){
     if(kyori % 2 == 0){
        list[ima]["color"] = list[oya]["color"];
     }else{
        if(list[oya]["color"] == 1){
           list[ima]["color"] = 0;
        }else{
           list[ima]["color"] = 1;
        }
     }
  }
  var children = Array.from(Object.keys(list[ima]["children"]));
  for(var i = 0; i < children.length; i++){
    if(children[i] != oya){
       var tmpKyori = list[ima]["children"][children[i]];
       dfs(children[i],ima,tmpKyori);
    }
  }
}
  var output = new Array(N);
  for(var i = 0; i < N; i++){
    output[i] = list[i]["color"];
  }
  myout(output.join("\n"));
}

function temple(){
  var obj = {};
  obj["children"] = {};
  obj["color"] = 0;
  return obj;
}