(n,),*t=[map(int,t.split())for t in open(0)]
*e,=eval('[],'*-~n)
q=[(1,0)]
f=[-1]*n
for v,w,c in t:e[v]+=(w,c),;e[w]+=(v,c),
for v,c in q:
 f[v-1]=c&1
 for w,d in e[v]:q+=[(w,c+d)]*(f[w-1]<0)
print(*f) map(int,t.split())for t in open(0) for t in open(0) t open(0) open 0 for t in open(0) map(int,t.split()) map int t.split() t.split t split (n,),*t=[map(int,t.split())for t in open(0)] n [map(int,t.split())for t in open(0)] *t t *e,=eval('[],'*-~n) *e e eval('[],'*-~n) eval '[],'*-~n '[],' -~n ~n n q=[(1,0)] q [(1,0)] (1,0) 1 0 f=[-1]*n f [-1]*n [-1] -1 n for v,w,c in t:e[v]+=(w,c),;e[w]+=(v,c), v w c t for v,c in q:
 f[v-1]=c&1
 for w,d in e[v]:q+=[(w,c+d)]*(f[w-1]<0) v c q f[v-1]=c&1 f[v-1] f v-1 v 1 c&1 c 1 for w,d in e[v]:q+=[(w,c+d)]*(f[w-1]<0 w d e[v] e v print(*f) print *f f q=[(1,0)] [(1,0)] q n,),*t=[map(int,t.split())for t in open(0)] [map(int,t.split())for t in open(0)] n f=[-1]*n [-1]*n f
(n,),*t=[map(int,t.split())for t in open(0)]
*e,=eval('[],'*-~n)
q=[(1,0)]
f=[-1]*n
for v,w,c in t:e[v]+=(w,c),;e[w]+=(v,c),
for v,c in q:
 f[v-1]=c&1
 for w,d in e[v]:q+=[(w,c+d)]*(f[w-1]<0)
print(*f)