import sys
sys.setrecursionlimit(10**9)

def dfs(now):
    for to,dis in G[now]:
        if color[to] == -1:
            color[to] = (color[now] + dis) % 2
            dfs(to)

N = int(input())
G = [[] for _ in range(N)]
color = [-1] * N
color[0] = 0 #偶数=0

for i in range(N-1):
    a,b,c = map(int,input().split())
    a -= 1
    b -= 1
    G[a].append([b,c%2])
    G[b].append([a,c%2])

#print(G)    
dfs(0)
print(*color,sep="\n") import sys sys sys.setrecursionlimit(10**9) sys.setrecursionlimit sys setrecursionlimit 10**9 10 9 def dfs(now):
    for to,dis in G[now]:
        if color[to] == -1:
            color[to] = (color[now] + dis) % 2
            dfs(to) dfs for to,dis in G[now]:
        if color[to] == -1:
            color[to] = (color[now] + dis) % 2
            dfs(to) to dis G[now] G now if color[to] == -1:
            color[to] = (color[now] + dis) % 2
            dfs(to) color[to] == -1 color[to] color to -1 color[to] = (color[now] + dis) % 2 color[to] color to (color[now] + dis) % 2 color[now] + dis color[now] color now dis 2 dfs(to) dfs to now now 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)] color = [-1] * N color [-1] * N [-1] -1 N color[0] = 0 color[0] color 0 0 for i in range(N-1):
    a,b,c = map(int,input().split())
    a -= 1
    b -= 1
    G[a].append([b,c%2])
    G[b].append([a,c%2])

#print(G)     i range(N-1) range N-1 N 1 a,b,c = map(int,input().split()) a map(int,input().split()) map int input().split() ().split () input split b c a -= 1 a 1 b -= 1 b 1 G[a].append([b,c%2]) [a].append [a] G a append [b,c%2] b c%2 c 2 G[b].append([a,c%2]) [b].append [b] G b append [a,c%2] a c%2 c 2 dfs(0) dfs 0 print(*color,sep="\n") print *color color sep="\n" sep "\n" color = [-1] * N [-1] * N color N = int(input()) int(input()) N def dfs(now):
    for to,dis in G[now]:
        if color[to] == -1:
            color[to] = (color[now] + dis) % 2
            dfs(to) def dfs(now):
    for to,dis in G[now]:
        if color[to] == -1:
            color[to] = (color[now] + dis) % 2
            dfs(to) dfs b -= 1 1 b G = [[] for _ in range(N)] [[] for _ in range(N)] G c = map(int,input().split()) map(int,input().split()) c a -= 1 1 a b,c = map(int,input().split()) map(int,input().split()) b a,b,c = map(int,input().split()) map(int,input().split()) a
import sys
sys.setrecursionlimit(10**9)

def dfs(now):
    for to,dis in G[now]:
        if color[to] == -1:
            color[to] = (color[now] + dis) % 2
            dfs(to)

N = int(input())
G = [[] for _ in range(N)]
color = [-1] * N
color[0] = 0 #偶数=0

for i in range(N-1):
    a,b,c = map(int,input().split())
    a -= 1
    b -= 1
    G[a].append([b,c%2])
    G[b].append([a,c%2])

#print(G)    
dfs(0)
print(*color,sep="\n")