import sys
sys.setrecursionlimit(1000000000)
input = sys.stdin.readline

N = int(input())
color = [-1]*N
graph = [[] for _ in range(N)]
for _ in range(N-1):
  u, v, w = map(int, input().split())
  u -= 1
  v -= 1
  graph[u] += [[v, w]]
  graph[v] += [[u, w]]

def dfs(u, c):
  color[u] = c
  for v, w in graph[u]:
    if color[v] == -1:
      if w % 2 == 0:
        dfs(v, c)
      else:
        dfs(v, abs(1-c))
  return

dfs(0, 0)
color = list(map(str, color))
print(*color)
 import sys sys sys.setrecursionlimit(1000000000) sys.setrecursionlimit sys setrecursionlimit 1000000000 input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline N = int(input()) N int(input()) int input() input color = [-1]*N color [-1]*N [-1] -1 N [] for _ in range(N) for _ in range(N) _ range(N) range N for _ in range(N) [] graph = [[] for _ in range(N)] graph [[] for _ in range(N)] for _ in range(N-1):
  u, v, w = map(int, input().split())
  u -= 1
  v -= 1
  graph[u] += [[v, w]]
  graph[v] += [[u, w]] _ 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 u -= 1 u 1 v -= 1 v 1 graph[u] += [[v, w]] graph[u] graph u [[v, w]] [v, w] v w graph[v] += [[u, w]] graph[v] graph v [[u, w]] [u, w] u w def dfs(u, c):
  color[u] = c
  for v, w in graph[u]:
    if color[v] == -1:
      if w % 2 == 0:
        dfs(v, c)
      else:
        dfs(v, abs(1-c))
  return dfs color[u] = c color[u] color u c for v, w in graph[u]:
    if color[v] == -1:
      if w % 2 == 0:
        dfs(v, c)
      else:
        dfs(v, abs(1-c))
   v w graph[u] graph u if color[v] == -1:
      if w % 2 == 0:
        dfs(v, c)
      else:
        dfs(v, abs(1-c))
   color[v] == -1 color[v] color v -1 if w % 2 == 0:
        dfs(v, c)
      else:
        dfs(v, abs(1-c))
   w % 2 == 0 w % 2 w 2 0 dfs(v, c) dfs v c dfs(v, abs(1-c)) dfs v abs(1-c) abs 1-c 1 c return u u c c dfs(0, 0) dfs 0 0 color = list(map(str, color)) color list(map(str, color)) list map(str, color) map str color print(*color) print *color color color = [-1]*N [-1]*N color graph = [[] for _ in range(N)] [[] for _ in range(N)] graph N = int(input()) int(input()) N w = map(int, input().split()) map(int, input().split()) w def dfs(u, c):
  color[u] = c
  for v, w in graph[u]:
    if color[v] == -1:
      if w % 2 == 0:
        dfs(v, c)
      else:
        dfs(v, abs(1-c))
  return def dfs(u, c):
  color[u] = c
  for v, w in graph[u]:
    if color[v] == -1:
      if w % 2 == 0:
        dfs(v, c)
      else:
        dfs(v, abs(1-c))
  return dfs v -= 1 1 v color = list(map(str, color)) list(map(str, color)) color v, w = map(int, input().split()) map(int, input().split()) v u, v, w = map(int, input().split()) map(int, input().split()) u u -= 1 1 u input = sys.stdin.readline sys.stdin.readline input
import sys
sys.setrecursionlimit(1000000000)
input = sys.stdin.readline

N = int(input())
color = [-1]*N
graph = [[] for _ in range(N)]
for _ in range(N-1):
  u, v, w = map(int, input().split())
  u -= 1
  v -= 1
  graph[u] += [[v, w]]
  graph[v] += [[u, w]]

def dfs(u, c):
  color[u] = c
  for v, w in graph[u]:
    if color[v] == -1:
      if w % 2 == 0:
        dfs(v, c)
      else:
        dfs(v, abs(1-c))
  return

dfs(0, 0)
color = list(map(str, color))
print(*color)

