#include<stdio.h>
int main(void){
  char *s="python3 -c\""
"n=int(input());e=[[]for _ in[0]*-~n];q=[(1,0)];f=[-1]*n\n"
"while n>1:v,w,c=map(int,input().split());e[v]+=(w,c),;e[w]+=(v,c),;n-=1\n"
"while q:\n"
" v,c=q.pop();f[v-1]=c%2\n"
" for w,d in e[v]:q+=[(w,c+d)]*(f[w-1]<0)\n"
"print(*f)\n"
"\"";
  system(s);
  return 0;
}            