
from collections import deque

n = int(input())
arr = [[] for _ in range(n) ]

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


queue = deque([0])
ans = [0]*n
checked = [0]*n

while queue:
    x =queue.popleft()
    checked[x] = -1
    dis = ans[x]
    for tup in arr[x]:
        if checked[tup[0]]> -1:
            ans[tup[0]]=(dis+tup[1])%2
            queue.append(tup[0])
print(*ans,sep='\n') from collections import deque 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) [] arr = [[] for _ in range(n) ] arr [[] for _ in range(n) ] for i in range(n-1):
    u,v,w =map(int,input().split())
    arr[u-1].append([v-1,w])
    arr[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 arr[u-1].append([v-1,w]) [u-1].append [u-1] arr u-1 u 1 append [v-1,w] v-1 v 1 w arr[v-1].append([u-1,w]) [v-1].append [v-1] arr v-1 v 1 append [u-1,w] u-1 u 1 w queue = deque([0]) queue deque([0]) deque [0] 0 ans = [0]*n ans [0]*n [0] 0 n checked = [0]*n checked [0]*n [0] 0 n while queue:
    x =queue.popleft()
    checked[x] = -1
    dis = ans[x]
    for tup in arr[x]:
        if checked[tup[0]]> -1:
            ans[tup[0]]=(dis+tup[1])%2
            queue.append(tup[0]) queue x =queue.popleft() x queue.popleft() queue.popleft queue popleft checked[x] = -1 checked[x] checked x -1 dis = ans[x] dis ans[x] ans x for tup in arr[x]:
        if checked[tup[0]]> -1:
            ans[tup[0]]=(dis+tup[1])%2
            queue.append(tup[0]) tup arr[x] arr x if checked[tup[0]]> -1:
            ans[tup[0]]=(dis+tup[1])%2
            queue.append(tup[0]) checked[tup[0]]> -1 checked[tup[0]] checked tup[0] tup 0 -1 ans[tup[0]]=(dis+tup[1])%2 ans[tup[0]] ans tup[0] tup 0 (dis+tup[1])%2 dis+tup[1] dis tup[1] tup 1 2 queue.append(tup[0]) queue.append queue append tup[0] tup 0 print(*ans,sep='\n') print *ans ans sep='\n' sep '\n' v,w =map(int,input().split()) map(int,input().split()) v ans = [0]*n [0]*n ans checked = [0]*n [0]*n checked queue = deque([0]) deque([0]) queue n = int(input()) int(input()) n dis = ans[x] ans[x] dis u,v,w =map(int,input().split()) map(int,input().split()) u x =queue.popleft() queue.popleft() x arr = [[] for _ in range(n) ] [[] for _ in range(n) ] arr w =map(int,input().split()) map(int,input().split()) w

from collections import deque

n = int(input())
arr = [[] for _ in range(n) ]

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


queue = deque([0])
ans = [0]*n
checked = [0]*n

while queue:
    x =queue.popleft()
    checked[x] = -1
    dis = ans[x]
    for tup in arr[x]:
        if checked[tup[0]]> -1:
            ans[tup[0]]=(dis+tup[1])%2
            queue.append(tup[0])
print(*ans,sep='\n')
