from collections import deque
n = int(input())
g = [[]for i in range(n)]
for _ in range(n-1):
  a, b, c = map(int, input().split())
  g[a-1].append([b-1,c])
  g[b-1].append([a-1,c])
ans = [0 for i in range(n)]
v = [-1 for i in range(n)]
v[0] = 0
d = deque([0])
while len(d):
  x = d.popleft()
  for i,j in g[x]:
    if v[i] == -1:
      d.append(i)
      b = ans[x] +j
      ans[i] = b
      if b%2 ==1:
        v[i] = 1
      else:
        v[i] = 0
print("\n".join(map(str,v))) 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 _ in range(n-1):
  a, b, c = map(int, input().split())
  g[a-1].append([b-1,c])
  g[b-1].append([a-1,c]) _ range(n-1) range n-1 n 1 a, b, c = map(int, input().split()) a map(int, input().split()) map int input().split() ().split () input split b c g[a-1].append([b-1,c]) [a-1].append [a-1] g a-1 a 1 append [b-1,c] b-1 b 1 c g[b-1].append([a-1,c]) [b-1].append [b-1] g b-1 b 1 append [a-1,c] a-1 a 1 c 0 for i in range(n) for i in range(n) i range(n) range n for i in range(n) 0 ans = [0 for i in range(n)] ans [0 for i in range(n)] -1 for i in range(n) for i in range(n) i range(n) range n for i in range(n) -1 v = [-1 for i in range(n)] v [-1 for i in range(n)] v[0] = 0 v[0] v 0 0 d = deque([0]) d deque([0]) deque [0] 0 while len(d):
  x = d.popleft()
  for i,j in g[x]:
    if v[i] == -1:
      d.append(i)
      b = ans[x] +j
      ans[i] = b
      if b%2 ==1:
        v[i] = 1
      else:
        v[i] = 0 len(d) len d x = d.popleft() x d.popleft() d.popleft d popleft for i,j in g[x]:
    if v[i] == -1:
      d.append(i)
      b = ans[x] +j
      ans[i] = b
      if b%2 ==1:
        v[i] = 1
      else:
        v[i] = 0 i j g[x] g x if v[i] == -1:
      d.append(i)
      b = ans[x] +j
      ans[i] = b
      if b%2 ==1:
        v[i] = 1
      else:
        v[i] = 0 v[i] == -1 v[i] v i -1 d.append(i) d.append d append i b = ans[x] +j b ans[x] +j ans[x] ans x j ans[i] = b ans[i] ans i b if b%2 ==1:
        v[i] = 1
      else:
        v[i] = 0 b%2 ==1 b%2 b 2 1 v[i] = 1 v[i] v i 1 v[i] = 0 v[i] v i 0 print("\n".join(map(str,v))) print "\n".join(map(str,v)) "\n".join "\n" join map(str,v) map str v n = int(input()) int(input()) n g = [[]for i in range(n)] [[]for i in range(n)] g b, c = map(int, input().split()) map(int, input().split()) b a, b, c = map(int, input().split()) map(int, input().split()) a c = map(int, input().split()) map(int, input().split()) c b = ans[x] +j ans[x] +j b d = deque([0]) deque([0]) d ans = [0 for i in range(n)] [0 for i in range(n)] ans v = [-1 for i in range(n)] [-1 for i in range(n)] v x = d.popleft() d.popleft() x
from collections import deque
n = int(input())
g = [[]for i in range(n)]
for _ in range(n-1):
  a, b, c = map(int, input().split())
  g[a-1].append([b-1,c])
  g[b-1].append([a-1,c])
ans = [0 for i in range(n)]
v = [-1 for i in range(n)]
v[0] = 0
d = deque([0])
while len(d):
  x = d.popleft()
  for i,j in g[x]:
    if v[i] == -1:
      d.append(i)
      b = ans[x] +j
      ans[i] = b
      if b%2 ==1:
        v[i] = 1
      else:
        v[i] = 0
print("\n".join(map(str,v)))