n=int(input())
a=[-1 for i in range(n)]
d=[[] for i in range(n)]
for i in range(n-1):
    u,v,w=map(int,input().split())
    u-=1
    v-=1
    d[u].append([v,w])
    d[v].append([u,w])
e=0
a[0]=0
l=[]
for i,j in d[0]:
    a[i]=(a[0]+j)%2
    l.append(i)
while len(l)>0:
    b=l.pop()
    for i,j in d[b]:
        if a[i]==-1:
            a[i]=(a[b]+j)%2
            l.append(i)
print(*a,sep='\n') n=int(input()) n int(input()) int input() input -1 for i in range(n) for i in range(n) i range(n) range n for i in range(n) -1 a=[-1 for i in range(n)] a [-1 for i in range(n)] [] for i in range(n) for i in range(n) i range(n) range n for i in range(n) [] d=[[] for i in range(n)] d [[] for i in range(n)] for i in range(n-1):
    u,v,w=map(int,input().split())
    u-=1
    v-=1
    d[u].append([v,w])
    d[v].append([u,w]) i range(n-1) range n-1 n 1 u,v,w=map(int,input().split()) u map(int,input().split()) map int input().split() ().split () input split v w u-=1 u 1 v-=1 v 1 d[u].append([v,w]) [u].append [u] d u append [v,w] v w d[v].append([u,w]) [v].append [v] d v append [u,w] u w e=0 e 0 a[0]=0 a[0] a 0 0 l=[] l [] for i,j in d[0]:
    a[i]=(a[0]+j)%2
    l.append(i) i j d[0] d 0 a[i]=(a[0]+j)%2 a[i] a i (a[0]+j)%2 a[0]+j a[0] a 0 j 2 l.append(i) l.append l append i while len(l)>0:
    b=l.pop()
    for i,j in d[b]:
        if a[i]==-1:
            a[i]=(a[b]+j)%2
            l.append(i) len(l)>0 len(l) len l 0 b=l.pop() b l.pop() l.pop l pop for i,j in d[b]:
        if a[i]==-1:
            a[i]=(a[b]+j)%2
            l.append(i) i j d[b] d b if a[i]==-1:
            a[i]=(a[b]+j)%2
            l.append(i) a[i]==-1 a[i] a i -1 a[i]=(a[b]+j)%2 a[i] a i (a[b]+j)%2 a[b]+j a[b] a b j 2 l.append(i) l.append l append i print(*a,sep='\n') print *a a sep='\n' sep '\n' a=[-1 for i in range(n)] [-1 for i in range(n)] a e=0 0 e v,w=map(int,input().split()) map(int,input().split()) v v-=1 1 v l=[] [] l u,v,w=map(int,input().split()) map(int,input().split()) u w=map(int,input().split()) map(int,input().split()) w d=[[] for i in range(n)] [[] for i in range(n)] d b=l.pop() l.pop() b n=int(input()) int(input()) n u-=1 1 u
n=int(input())
a=[-1 for i in range(n)]
d=[[] for i in range(n)]
for i in range(n-1):
    u,v,w=map(int,input().split())
    u-=1
    v-=1
    d[u].append([v,w])
    d[v].append([u,w])
e=0
a[0]=0
l=[]
for i,j in d[0]:
    a[i]=(a[0]+j)%2
    l.append(i)
while len(l)>0:
    b=l.pop()
    for i,j in d[b]:
        if a[i]==-1:
            a[i]=(a[b]+j)%2
            l.append(i)
print(*a,sep='\n')