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

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 i in range(1,N):
    if di[i]!=-1:continue
    seen=[0]*N
    stack=[[0,0]]
    while stack:
        y,d=stack.pop()
        if seen[y]==1:continue
        seen[y]=1
        for z, dist in G[y]:
            if seen[z] == 0:
                di[z] = d + dist
                stack.append([z, d + dist])

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