import sys
readline = sys.stdin.readline

# スタートを0で塗り、行先が奇数であれば違う色で塗る、を繰り返せばよい
N = int(readline())
G = [[] for i in range(N)]

for i in range(N - 1):
  u,v,w = map(int,readline().split())
  G[u - 1].append([v - 1, w])
  G[v - 1].append([u - 1, w])

ans = [-1] * N

stack = []
# 頂点, 色
stack.append([0,0])
while stack:
  v,color = stack.pop()
  if ans[v] != -1:
    continue
  ans[v] = color
  for child in G[v]:
    col = color
    if child[1] % 2 == 1:
      col ^= 1
    stack.append([child[0], col])

for a in ans:
  print(a) import sys sys readline = sys.stdin.readline readline sys.stdin.readline sys.stdin sys stdin readline N = int(readline()) N int(readline()) int readline() readline [] for i in range(N) for i in range(N) i range(N) range N for i in range(N) [] G = [[] for i in range(N)] G [[] for i in range(N)] for i in range(N - 1):
  u,v,w = map(int,readline().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,readline().split()) u map(int,readline().split()) map int readline().split() ().split () readline 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 ans = [-1] * N ans [-1] * N [-1] -1 N stack = [] stack [] stack.append([0,0]) stack.append stack append [0,0] 0 0 while stack:
  v,color = stack.pop()
  if ans[v] != -1:
    continue
  ans[v] = color
  for child in G[v]:
    col = color
    if child[1] % 2 == 1:
      col ^= 1
    stack.append([child[0], col]) stack v,color = stack.pop() v stack.pop() stack.pop stack pop color if ans[v] != -1:
    continue
   ans[v] != -1 ans[v] ans v -1 continue ans[v] = color ans[v] ans v color for child in G[v]:
    col = color
    if child[1] % 2 == 1:
      col ^= 1
    stack.append([child[0], col]) child G[v] G v col = color col color if child[1] % 2 == 1:
      col ^= 1
     child[1] % 2 == 1 child[1] % 2 child[1] child 1 2 1 col ^= 1 col 1 stack.append([child[0], col]) stack.append stack append [child[0], col] child[0] child 0 col for a in ans:
  print(a) a ans print(a) print a col ^= 1 1 col v,w = map(int,readline().split()) map(int,readline().split()) v v,color = stack.pop() stack.pop() v w = map(int,readline().split()) map(int,readline().split()) w u,v,w = map(int,readline().split()) map(int,readline().split()) u stack = [] [] stack color = stack.pop() stack.pop() color col = color color col N = int(readline()) int(readline()) N ans = [-1] * N [-1] * N ans readline = sys.stdin.readline sys.stdin.readline readline G = [[] for i in range(N)] [[] for i in range(N)] G
import sys
readline = sys.stdin.readline

# スタートを0で塗り、行先が奇数であれば違う色で塗る、を繰り返せばよい
N = int(readline())
G = [[] for i in range(N)]

for i in range(N - 1):
  u,v,w = map(int,readline().split())
  G[u - 1].append([v - 1, w])
  G[v - 1].append([u - 1, w])

ans = [-1] * N

stack = []
# 頂点, 色
stack.append([0,0])
while stack:
  v,color = stack.pop()
  if ans[v] != -1:
    continue
  ans[v] = color
  for child in G[v]:
    col = color
    if child[1] % 2 == 1:
      col ^= 1
    stack.append([child[0], col])

for a in ans:
  print(a)