
from copy import copy
N=int(input())
G=[[] for _ in range(N)]
di=[-1]*N
for i in range(N-1):
    u,v,w=map(int,input().split())
    G[u-1].append([v-1,w])
    G[v-1].append([u-1,w])

di[0]=0
for g,w in G[0]:
    di[g]=w

for i in range(1,N):
    if di[i]!=-1:continue
    seen=[0]*N
    stack=copy(G[0])
    seen[0]=1
    dis=0
    while stack:
        y,d=stack.pop()
        if seen[y]==1:continue
        seen[y]=1
        if y==i:
            di[i]=dis+d
            break
        else:
            for z,dist in G[y]:
                if seen[z]==0:
                    di[z]=dis+d+dist
                    stack.append([z,dis+d+dist])

for i in range(N):
    if di[i]%2==0:
        print(0)
    else:
        print(1) from copy import copy N=int(input()) N int(input()) int input() input [] for _ in range(N) for _ in range(N) _ range(N) range N for _ in range(N) [] G=[[] for _ in range(N)] G [[] for _ in range(N)] di=[-1]*N di [-1]*N [-1] -1 N for i in range(N-1):
    u,v,w=map(int,input().split())
    G[u-1].append([v-1,w])
    G[v-1].append([u-1,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 G[u-1].append([v-1,w]) [u-1].append [u-1] G u-1 u 1 append [v-1,w] v-1 v 1 w G[v-1].append([u-1,w]) [v-1].append [v-1] G v-1 v 1 append [u-1,w] u-1 u 1 w di[0]=0 di[0] di 0 0 for g,w in G[0]:
    di[g]=w g w G[0] G 0 di[g]=w di[g] di g w for i in range(1,N):
    if di[i]!=-1:continue
    seen=[0]*N
    stack=copy(G[0])
    seen[0]=1
    dis=0
    while stack:
        y,d=stack.pop()
        if seen[y]==1:continue
        seen[y]=1
        if y==i:
            di[i]=dis+d
            break
        else:
            for z,dist in G[y]:
                if seen[z]==0:
                    di[z]=dis+d+dist
                    stack.append([z,dis+d+dist]) i range(1,N) range 1 N if di[i]!=-1:continue
     di[i]!=-1 di[i] di i -1 seen=[0]*N seen [0]*N [0] 0 N stack=copy(G[0]) stack copy(G[0]) copy G[0] G 0 seen[0]=1 seen[0] seen 0 1 dis=0 dis 0 while stack:
        y,d=stack.pop()
        if seen[y]==1:continue
        seen[y]=1
        if y==i:
            di[i]=dis+d
            break
        else:
            for z,dist in G[y]:
                if seen[z]==0:
                    di[z]=dis+d+dist
                    stack.append([z,dis+d+dist]) stack y,d=stack.pop() y stack.pop() stack.pop stack pop d if seen[y]==1:continue
         seen[y]==1 seen[y] seen y 1 seen[y]=1 seen[y] seen y 1 if y==i:
            di[i]=dis+d
            break
        else:
            for z,dist in G[y]:
                if seen[z]==0:
                    di[z]=dis+d+dist
                    stack.append([z,dis+d+dist]) y==i y i di[i]=dis+d di[i] di i dis+d dis d break for z,dist in G[y]:
                if seen[z]==0:
                    di[z]=dis+d+dist
                    stack.append([z,dis+d+dist]) z dist G[y] G y if seen[z]==0:
                    di[z]=dis+d+dist
                    stack.append([z,dis+d+dist]) seen[z]==0 seen[z] seen z 0 di[z]=dis+d+dist di[z] di z dis+d+dist dis+d dis d dist stack.append([z,dis+d+dist]) stack.append stack append [z,dis+d+dist] z dis+d+dist dis+d dis d dist for i in range(N):
    if di[i]%2==0:
        print(0)
    else:
        print(1) i range(N) range N if di[i]%2==0:
        print(0)
    else:
        print(1) di[i]%2==0 di[i]%2 di[i] di i 2 0 print(0) print 0 print(1) print 1 G=[[] for _ in range(N)] [[] for _ in range(N)] G dis=0 0 dis v,w=map(int,input().split()) map(int,input().split()) v seen=[0]*N [0]*N seen N=int(input()) int(input()) N u,v,w=map(int,input().split()) map(int,input().split()) u w=map(int,input().split()) map(int,input().split()) w stack=copy(G[0]) copy(G[0]) stack d=stack.pop() stack.pop() d di=[-1]*N [-1]*N di y,d=stack.pop() stack.pop() y

from copy import copy
N=int(input())
G=[[] for _ in range(N)]
di=[-1]*N
for i in range(N-1):
    u,v,w=map(int,input().split())
    G[u-1].append([v-1,w])
    G[v-1].append([u-1,w])

di[0]=0
for g,w in G[0]:
    di[g]=w

for i in range(1,N):
    if di[i]!=-1:continue
    seen=[0]*N
    stack=copy(G[0])
    seen[0]=1
    dis=0
    while stack:
        y,d=stack.pop()
        if seen[y]==1:continue
        seen[y]=1
        if y==i:
            di[i]=dis+d
            break
        else:
            for z,dist in G[y]:
                if seen[z]==0:
                    di[z]=dis+d+dist
                    stack.append([z,dis+d+dist])

for i in range(N):
    if di[i]%2==0:
        print(0)
    else:
        print(1)