dic = {1:0,0:1}

from collections import deque 
#スタック
q = deque([])#append pop

N = int(input())
#木
tree = [[]for i in range(0,N+1,1)]
for i in range(1,N,1):
    u,v,w = map(int,input().split())
    tree[u].append([v,w])
    tree[v].append([u,w])
ans = [0]*(N+1)

q.append([1,0,0])#今回のノード、距離、前回のノード

while len(q)>0:
    now,dist,pre = q.pop()
    ans[now] = (ans[pre] + dist%2)%2
    for i in tree[now]:
        if i[0]!=pre:
            q.append([i[0],i[1],now])

for i in range(1,N+1,1):
    print(ans[i]) dic = {1:0,0:1} dic {1:0,0:1} 1 1 0 0 0 1 from collections import deque q = deque([]) q deque([]) deque [] N = int(input()) N int(input()) int input() input []for i in range(0,N+1,1) for i in range(0,N+1,1) i range(0,N+1,1) range 0 N+1 N 1 1 for i in range(0,N+1,1) [] tree = [[]for i in range(0,N+1,1)] tree [[]for i in range(0,N+1,1)] for i in range(1,N,1):
    u,v,w = map(int,input().split())
    tree[u].append([v,w])
    tree[v].append([u,w]) i range(1,N,1) range 1 N 1 u,v,w = map(int,input().split()) u map(int,input().split()) map int input().split() ().split () input split v w tree[u].append([v,w]) [u].append [u] tree u append [v,w] v w tree[v].append([u,w]) [v].append [v] tree v append [u,w] u w ans = [0]*(N+1) ans [0]*(N+1) [0] 0 N+1 N 1 q.append([1,0,0]) q.append q append [1,0,0] 1 0 0 while len(q)>0:
    now,dist,pre = q.pop()
    ans[now] = (ans[pre] + dist%2)%2
    for i in tree[now]:
        if i[0]!=pre:
            q.append([i[0],i[1],now]) len(q)>0 len(q) len q 0 now,dist,pre = q.pop() now q.pop() q.pop q pop dist pre ans[now] = (ans[pre] + dist%2)%2 ans[now] ans now (ans[pre] + dist%2)%2 ans[pre] + dist%2 ans[pre] ans pre dist%2 dist 2 2 for i in tree[now]:
        if i[0]!=pre:
            q.append([i[0],i[1],now]) i tree[now] tree now if i[0]!=pre:
            q.append([i[0],i[1],now]) i[0]!=pre i[0] i 0 pre q.append([i[0],i[1],now]) q.append q append [i[0],i[1],now] i[0] i 0 i[1] i 1 now for i in range(1,N+1,1):
    print(ans[i]) i range(1,N+1,1) range 1 N+1 N 1 1 print(ans[i]) print ans[i] ans i u,v,w = map(int,input().split()) map(int,input().split()) u dist,pre = q.pop() q.pop() dist ans = [0]*(N+1) [0]*(N+1) ans N = int(input()) int(input()) N now,dist,pre = q.pop() q.pop() now pre = q.pop() q.pop() pre q = deque([]) deque([]) q dic = {1:0,0:1} {1:0,0:1} dic tree = [[]for i in range(0,N+1,1)] [[]for i in range(0,N+1,1)] tree w = map(int,input().split()) map(int,input().split()) w v,w = map(int,input().split()) map(int,input().split()) v
dic = {1:0,0:1}

from collections import deque 
#スタック
q = deque([])#append pop

N = int(input())
#木
tree = [[]for i in range(0,N+1,1)]
for i in range(1,N,1):
    u,v,w = map(int,input().split())
    tree[u].append([v,w])
    tree[v].append([u,w])
ans = [0]*(N+1)

q.append([1,0,0])#今回のノード、距離、前回のノード

while len(q)>0:
    now,dist,pre = q.pop()
    ans[now] = (ans[pre] + dist%2)%2
    for i in tree[now]:
        if i[0]!=pre:
            q.append([i[0],i[1],now])

for i in range(1,N+1,1):
    print(ans[i])