n=int(input())
L=[[] for i in range(n+1)]
for i in range(n-1):
    u,v,w=map(int,input().split())
    L[u].append((v,w%2))
    L[v].append((u,w%2))

V=[0 for i in range(n+1)]
V[1]=1
ans=[0 for i in range(n+1)]
que=[1]
head=0

while len(que)>head:
    now=que[head]
    head+=1
    for nex in L[now]:
        if V[nex[0]]==0:
            V[nex[0]]=1
            ans[nex[0]]=ans[now]^nex[1]
            que.append(nex[0])
    
for pri in ans[1:]:
    print(pri) n=int(input()) n int(input()) int input() input [] for i in range(n+1) for i in range(n+1) i range(n+1) range n+1 n 1 for i in range(n+1) [] L=[[] for i in range(n+1)] L [[] for i in range(n+1)] for i in range(n-1):
    u,v,w=map(int,input().split())
    L[u].append((v,w%2))
    L[v].append((u,w%2)) 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 L[u].append((v,w%2)) [u].append [u] L u append (v,w%2) v w%2 w 2 L[v].append((u,w%2)) [v].append [v] L v append (u,w%2) u w%2 w 2 0 for i in range(n+1) for i in range(n+1) i range(n+1) range n+1 n 1 for i in range(n+1) 0 V=[0 for i in range(n+1)] V [0 for i in range(n+1)] V[1]=1 V[1] V 1 1 0 for i in range(n+1) for i in range(n+1) i range(n+1) range n+1 n 1 for i in range(n+1) 0 ans=[0 for i in range(n+1)] ans [0 for i in range(n+1)] que=[1] que [1] 1 head=0 head 0 while len(que)>head:
    now=que[head]
    head+=1
    for nex in L[now]:
        if V[nex[0]]==0:
            V[nex[0]]=1
            ans[nex[0]]=ans[now]^nex[1]
            que.append(nex[0])
     len(que)>head len(que) len que head now=que[head] now que[head] que head head+=1 head 1 for nex in L[now]:
        if V[nex[0]]==0:
            V[nex[0]]=1
            ans[nex[0]]=ans[now]^nex[1]
            que.append(nex[0])
     nex L[now] L now if V[nex[0]]==0:
            V[nex[0]]=1
            ans[nex[0]]=ans[now]^nex[1]
            que.append(nex[0])
     V[nex[0]]==0 V[nex[0]] V nex[0] nex 0 0 V[nex[0]]=1 V[nex[0]] V nex[0] nex 0 1 ans[nex[0]]=ans[now]^nex[1] ans[nex[0]] ans nex[0] nex 0 ans[now]^nex[1] ans[now] ans now nex[1] nex 1 que.append(nex[0]) que.append que append nex[0] nex 0 for pri in ans[1:]:
    print(pri) pri ans[1:] ans 1: 1 print(pri) print pri n=int(input()) int(input()) n que=[1] [1] que L=[[] for i in range(n+1)] [[] for i in range(n+1)] L ans=[0 for i in range(n+1)] [0 for i in range(n+1)] ans V=[0 for i in range(n+1)] [0 for i in range(n+1)] V u,v,w=map(int,input().split()) map(int,input().split()) u v,w=map(int,input().split()) map(int,input().split()) v w=map(int,input().split()) map(int,input().split()) w head=0 0 head head+=1 1 head now=que[head] que[head] now
n=int(input())
L=[[] for i in range(n+1)]
for i in range(n-1):
    u,v,w=map(int,input().split())
    L[u].append((v,w%2))
    L[v].append((u,w%2))

V=[0 for i in range(n+1)]
V[1]=1
ans=[0 for i in range(n+1)]
que=[1]
head=0

while len(que)>head:
    now=que[head]
    head+=1
    for nex in L[now]:
        if V[nex[0]]==0:
            V[nex[0]]=1
            ans[nex[0]]=ans[now]^nex[1]
            que.append(nex[0])
    
for pri in ans[1:]:
    print(pri)