import sys
readline = sys.stdin.readline

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))
  
color = [-1] * N
stack = []
stack.append([0, -1, 0])
while stack:
  v,parent,cost = stack.pop()
  color[v] = cost
  for child in G[v]:
    if child[0] == parent:
      continue
    stack.append([child[0], v, (cost + child[1]) % 2])

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

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))
  
color = [-1] * N
stack = []
stack.append([0, -1, 0])
while stack:
  v,parent,cost = stack.pop()
  color[v] = cost
  for child in G[v]:
    if child[0] == parent:
      continue
    stack.append([child[0], v, (cost + child[1]) % 2])

for c in color:
  print(c)