import sys
sys.setrecursionlimit(10**9)
def dfs(i):
  if reached[i] == 1:
    return
  reached[i] = 1
  for dic in uv[i]:
    to = dic["to"]
    w = dic["weight"]
    if w % 2 == 0:
      color[to] = color[i]
    else:
      color[to] = int(not color[i])
    dfs(to)

n = int(input())
color = [0]*(n+1)
reached = [0]*(n+1)
uv = [[] * (n+1) for i in range(n+1)]
for i in range(n-1):
  u,v,w = map(int,input().split())
  uv[u].append({"to":v, "weight":w})
  uv[v].append({"to":u, "weight":w})
dfs(1)
for i in color[1:]:
  print(i) import sys sys sys.setrecursionlimit(10**9) sys.setrecursionlimit sys setrecursionlimit 10**9 10 9 def dfs(i):
  if reached[i] == 1:
    return
  reached[i] = 1
  for dic in uv[i]:
    to = dic["to"]
    w = dic["weight"]
    if w % 2 == 0:
      color[to] = color[i]
    else:
      color[to] = int(not color[i])
    dfs(to) dfs if reached[i] == 1:
    return
   reached[i] == 1 reached[i] reached i 1 return reached[i] = 1 reached[i] reached i 1 for dic in uv[i]:
    to = dic["to"]
    w = dic["weight"]
    if w % 2 == 0:
      color[to] = color[i]
    else:
      color[to] = int(not color[i])
    dfs(to) dic uv[i] uv i to = dic["to"] to dic["to"] dic "to" w = dic["weight"] w dic["weight"] dic "weight" if w % 2 == 0:
      color[to] = color[i]
    else:
      color[to] = int(not color[i])
     w % 2 == 0 w % 2 w 2 0 color[to] = color[i] color[to] color to color[i] color i color[to] = int(not color[i]) color[to] color to int(not color[i]) int not color[i] color[i] color i dfs(to) dfs to i i n = int(input()) n int(input()) int input() input color = [0]*(n+1) color [0]*(n+1) [0] 0 n+1 n 1 reached = [0]*(n+1) reached [0]*(n+1) [0] 0 n+1 n 1 [] * (n+1) for i in range(n+1) for i in range(n+1) i range(n+1) range n+1 n 1 for i in range(n+1) [] * (n+1) [] n+1 n 1 uv = [[] * (n+1) for i in range(n+1)] uv [[] * (n+1) for i in range(n+1)] for i in range(n-1):
  u,v,w = map(int,input().split())
  uv[u].append({"to":v, "weight":w})
  uv[v].append({"to":u, "weight":w}) i 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 uv[u].append({"to":v, "weight":w}) [u].append [u] uv u append {"to":v, "weight":w} "to" "to" v "weight" "weight" w uv[v].append({"to":u, "weight":w}) [v].append [v] uv v append {"to":u, "weight":w} "to" "to" u "weight" "weight" w dfs(1) dfs 1 for i in color[1:]:
  print(i) i color[1:] color 1: 1 print(i) print i def dfs(i):
  if reached[i] == 1:
    return
  reached[i] = 1
  for dic in uv[i]:
    to = dic["to"]
    w = dic["weight"]
    if w % 2 == 0:
      color[to] = color[i]
    else:
      color[to] = int(not color[i])
    dfs(to) def dfs(i):
  if reached[i] == 1:
    return
  reached[i] = 1
  for dic in uv[i]:
    to = dic["to"]
    w = dic["weight"]
    if w % 2 == 0:
      color[to] = color[i]
    else:
      color[to] = int(not color[i])
    dfs(to) dfs n = int(input()) int(input()) n u,v,w = map(int,input().split()) map(int,input().split()) u w = map(int,input().split()) map(int,input().split()) w reached = [0]*(n+1) [0]*(n+1) reached uv = [[] * (n+1) for i in range(n+1)] [[] * (n+1) for i in range(n+1)] uv v,w = map(int,input().split()) map(int,input().split()) v color = [0]*(n+1) [0]*(n+1) color
import sys
sys.setrecursionlimit(10**9)
def dfs(i):
  if reached[i] == 1:
    return
  reached[i] = 1
  for dic in uv[i]:
    to = dic["to"]
    w = dic["weight"]
    if w % 2 == 0:
      color[to] = color[i]
    else:
      color[to] = int(not color[i])
    dfs(to)

n = int(input())
color = [0]*(n+1)
reached = [0]*(n+1)
uv = [[] * (n+1) for i in range(n+1)]
for i in range(n-1):
  u,v,w = map(int,input().split())
  uv[u].append({"to":v, "weight":w})
  uv[v].append({"to":u, "weight":w})
dfs(1)
for i in color[1:]:
  print(i)