from collections import deque
N=int(input())
lst=[[] for i in range(N)]
for i in range(N-1):
    U,V,W=map(int,input().split())
    lst[U-1].append([U-1,V-1,W])
    lst[V-1].append([V-1,U-1,W])

ans_lst=[-1]*N
queue=deque([])
for i in lst[0]:
    queue.append(i)
ans_lst[0]=0
while queue:
    u,v,w=queue.popleft()
    if ans_lst[v]==-1:
        ans_lst[v]=(ans_lst[u]+w)%2
        for i in lst[v]:
            queue.append(i)

for i in ans_lst:
    print(i) from collections import deque N=int(input()) N int(input()) int input() input [] for i in range(N) for i in range(N) i range(N) range N for i in range(N) [] lst=[[] for i in range(N)] lst [[] for i in range(N)] for i in range(N-1):
    U,V,W=map(int,input().split())
    lst[U-1].append([U-1,V-1,W])
    lst[V-1].append([V-1,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 lst[U-1].append([U-1,V-1,W]) [U-1].append [U-1] lst U-1 U 1 append [U-1,V-1,W] U-1 U 1 V-1 V 1 W lst[V-1].append([V-1,U-1,W]) [V-1].append [V-1] lst V-1 V 1 append [V-1,U-1,W] V-1 V 1 U-1 U 1 W ans_lst=[-1]*N ans_lst [-1]*N [-1] -1 N queue=deque([]) queue deque([]) deque [] for i in lst[0]:
    queue.append(i) i lst[0] lst 0 queue.append(i) queue.append queue append i ans_lst[0]=0 ans_lst[0] ans_lst 0 0 while queue:
    u,v,w=queue.popleft()
    if ans_lst[v]==-1:
        ans_lst[v]=(ans_lst[u]+w)%2
        for i in lst[v]:
            queue.append(i) queue u,v,w=queue.popleft() u queue.popleft() queue.popleft queue popleft v w if ans_lst[v]==-1:
        ans_lst[v]=(ans_lst[u]+w)%2
        for i in lst[v]:
            queue.append(i) ans_lst[v]==-1 ans_lst[v] ans_lst v -1 ans_lst[v]=(ans_lst[u]+w)%2 ans_lst[v] ans_lst v (ans_lst[u]+w)%2 ans_lst[u]+w ans_lst[u] ans_lst u w 2 for i in lst[v]:
            queue.append(i) i lst[v] lst v queue.append(i) queue.append queue append i for i in ans_lst:
    print(i) i ans_lst print(i) print i u,v,w=queue.popleft() queue.popleft() u W=map(int,input().split()) map(int,input().split()) W V,W=map(int,input().split()) map(int,input().split()) V ans_lst=[-1]*N [-1]*N ans_lst lst=[[] for i in range(N)] [[] for i in range(N)] lst N=int(input()) int(input()) N U,V,W=map(int,input().split()) map(int,input().split()) U queue=deque([]) deque([]) queue v,w=queue.popleft() queue.popleft() v w=queue.popleft() queue.popleft() w
from collections import deque
N=int(input())
lst=[[] for i in range(N)]
for i in range(N-1):
    U,V,W=map(int,input().split())
    lst[U-1].append([U-1,V-1,W])
    lst[V-1].append([V-1,U-1,W])

ans_lst=[-1]*N
queue=deque([])
for i in lst[0]:
    queue.append(i)
ans_lst[0]=0
while queue:
    u,v,w=queue.popleft()
    if ans_lst[v]==-1:
        ans_lst[v]=(ans_lst[u]+w)%2
        for i in lst[v]:
            queue.append(i)

for i in ans_lst:
    print(i)