

function Main(input) {
  input = input.split("\n");
  var N = parseInt(input[0]);
  var wb = new Array(N).fill(0);
  var e = new Array(N-1);
  var list = new Array(N);
  for(var i=0;i<N-1;i++){
    var tmp=[parseInt(input[i+1].split(" ")[0]),parseInt(input[i+1].split(" ")[1]),parseInt(input[i+1].split(" ")[2])];
    e[i]=tmp;
    if(list[tmp[0]]==undefined){
      list[tmp[0]]=[[tmp[1],tmp[2]%2]];
    }else{
      list[tmp[0]].push([tmp[1],tmp[2]%2]);
    }
  }
  for(var i=0;i<N;i++){
    if(list[i]!=undefined){
      for(var j=0;j<list[i].length;j++){
        if(list[i][j][1]==1){
          if(wb[i-1]==0){
            wb[list[i][j][0]-1]=1;
          }else{
            wb[list[i][j][0]-1]=0;
          }
        }
      }
    }
  }
  var ans = wb.join("\n");


  

  console.log('%s', ans);
  return ans;
}

function debug(n){
  var input = document.getElementById("input"+n).value;
  var ans=Main(input);
  var result="WA";
  if(ans==document.getElementById("output"+n).value.split("\n")[0]){
    result="AC";
  }
  document.getElementById("result"+n).innerHTML=result;
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));