from collections import deque
N = int(input())
#隣接リスト
g = [[] for i in range(N)]
for i in range(N-1):
  u,v,w = map(int,input().split())
  g[u-1].append([v-1,w])
  g[v-1].append([u-1,w])
q = deque()
#通ったかどうか
check = [0] * N
check[0] = 1
q.append(0)
ans = [-1] * N
ans[0] = 0
while len(q) > 0:
  e = q.popleft()
  for i,j in g[e]:
    if check[i] == 1:
      continue
    ans[i] = (ans[e] + j) %2
    check[i] = 1
    q.append(i)
for i in range(N):
  print(ans[i]) from collections import deque N = int(input()) N int(input()) int input() input [] 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,input().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,input().split()) u map(int,input().split()) map int input().split() ().split () input 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 q = deque() q deque() deque check = [0] * N check [0] * N [0] 0 N check[0] = 1 check[0] check 0 1 q.append(0) q.append q append 0 ans = [-1] * N ans [-1] * N [-1] -1 N ans[0] = 0 ans[0] ans 0 0 while len(q) > 0:
  e = q.popleft()
  for i,j in g[e]:
    if check[i] == 1:
      continue
    ans[i] = (ans[e] + j) %2
    check[i] = 1
    q.append(i) len(q) > 0 len(q) len q 0 e = q.popleft() e q.popleft() q.popleft q popleft for i,j in g[e]:
    if check[i] == 1:
      continue
    ans[i] = (ans[e] + j) %2
    check[i] = 1
    q.append(i) i j g[e] g e if check[i] == 1:
      continue
     check[i] == 1 check[i] check i 1 continue ans[i] = (ans[e] + j) %2 ans[i] ans i (ans[e] + j) %2 ans[e] + j ans[e] ans e j 2 check[i] = 1 check[i] check i 1 q.append(i) q.append q append i for i in range(N):
  print(ans[i]) i range(N) range N print(ans[i]) print ans[i] ans i q = deque() deque() q u,v,w = map(int,input().split()) map(int,input().split()) u check = [0] * N [0] * N check g = [[] for i in range(N)] [[] for i in range(N)] g v,w = map(int,input().split()) map(int,input().split()) v e = q.popleft() q.popleft() e w = map(int,input().split()) map(int,input().split()) w ans = [-1] * N [-1] * N ans N = int(input()) int(input()) N
from collections import deque
N = int(input())
#隣接リスト
g = [[] for i in range(N)]
for i in range(N-1):
  u,v,w = map(int,input().split())
  g[u-1].append([v-1,w])
  g[v-1].append([u-1,w])
q = deque()
#通ったかどうか
check = [0] * N
check[0] = 1
q.append(0)
ans = [-1] * N
ans[0] = 0
while len(q) > 0:
  e = q.popleft()
  for i,j in g[e]:
    if check[i] == 1:
      continue
    ans[i] = (ans[e] + j) %2
    check[i] = 1
    q.append(i)
for i in range(N):
  print(ans[i])
