from collections import deque

N = int(input())
dic = {i:[] for i in range(1,N+1)}

for _ in range(N-1):
  u, v, w = map(int, input().split())
  dic[u].append((v,w))
  dic[v].append((u,w))
  
s1 = set([1])
s2 = set([])
h = deque([(1,0)])

while h:
  p = h.popleft()
  for t in dic[p[0]]:
    if t[0] == p[1]:
      continue
    if t[1]%2 == 0:
      if p[0] in s1:
        s1.add(t[0])
      else:
        s2.add(t[0])
    else:
      if p[0] in s1:
        s2.add(t[0])
      else:
        s1.add(t[0])
    h.append((t[0],p[0]))

for i in range(1,N+1):
  if i in s1:
    print(0)
  elif i in s2:
    print(1) from collections import deque N = int(input()) N int(input()) int input() input i:[] for i in range(1,N+1) for i in range(1,N+1) i range(1,N+1) range 1 N+1 N 1 for i in range(1,N+1) i [] dic = {i:[] for i in range(1,N+1)} dic {i:[] for i in range(1,N+1)} for _ in range(N-1):
  u, v, w = map(int, input().split())
  dic[u].append((v,w))
  dic[v].append((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 dic[u].append((v,w)) [u].append [u] dic u append (v,w) v w dic[v].append((u,w)) [v].append [v] dic v append (u,w) u w s1 = set([1]) s1 set([1]) set [1] 1 s2 = set([]) s2 set([]) set [] h = deque([(1,0)]) h deque([(1,0)]) deque [(1,0)] (1,0) 1 0 while h:
  p = h.popleft()
  for t in dic[p[0]]:
    if t[0] == p[1]:
      continue
    if t[1]%2 == 0:
      if p[0] in s1:
        s1.add(t[0])
      else:
        s2.add(t[0])
    else:
      if p[0] in s1:
        s2.add(t[0])
      else:
        s1.add(t[0])
    h.append((t[0],p[0])) h p = h.popleft() p h.popleft() h.popleft h popleft for t in dic[p[0]]:
    if t[0] == p[1]:
      continue
    if t[1]%2 == 0:
      if p[0] in s1:
        s1.add(t[0])
      else:
        s2.add(t[0])
    else:
      if p[0] in s1:
        s2.add(t[0])
      else:
        s1.add(t[0])
    h.append((t[0],p[0])) t dic[p[0]] dic p[0] p 0 if t[0] == p[1]:
      continue
     t[0] == p[1] t[0] t 0 p[1] p 1 continue if t[1]%2 == 0:
      if p[0] in s1:
        s1.add(t[0])
      else:
        s2.add(t[0])
    else:
      if p[0] in s1:
        s2.add(t[0])
      else:
        s1.add(t[0])
     t[1]%2 == 0 t[1]%2 t[1] t 1 2 0 if p[0] in s1:
        s1.add(t[0])
      else:
        s2.add(t[0])
     p[0] in s1 p[0] p 0 s1 s1.add(t[0]) s1.add s1 add t[0] t 0 s2.add(t[0]) s2.add s2 add t[0] t 0 if p[0] in s1:
        s2.add(t[0])
      else:
        s1.add(t[0])
     p[0] in s1 p[0] p 0 s1 s2.add(t[0]) s2.add s2 add t[0] t 0 s1.add(t[0]) s1.add s1 add t[0] t 0 h.append((t[0],p[0])) h.append h append (t[0],p[0]) t[0] t 0 p[0] p 0 for i in range(1,N+1):
  if i in s1:
    print(0)
  elif i in s2:
    print(1) i range(1,N+1) range 1 N+1 N 1 if i in s1:
    print(0)
  elif i in s2:
    print(1) i in s1 i s1 print(0) print 0 elif i in s2:
    print(1) i in s2 i s2 print(1) print 1 N = int(input()) int(input()) N p = h.popleft() h.popleft() p w = map(int, input().split()) map(int, input().split()) w s2 = set([]) set([]) s2 u, v, w = map(int, input().split()) map(int, input().split()) u h = deque([(1,0)]) deque([(1,0)]) h s1 = set([1]) set([1]) s1 dic = {i:[] for i in range(1,N+1)} {i:[] for i in range(1,N+1)} dic v, w = map(int, input().split()) map(int, input().split()) v
from collections import deque

N = int(input())
dic = {i:[] for i in range(1,N+1)}

for _ in range(N-1):
  u, v, w = map(int, input().split())
  dic[u].append((v,w))
  dic[v].append((u,w))
  
s1 = set([1])
s2 = set([])
h = deque([(1,0)])

while h:
  p = h.popleft()
  for t in dic[p[0]]:
    if t[0] == p[1]:
      continue
    if t[1]%2 == 0:
      if p[0] in s1:
        s1.add(t[0])
      else:
        s2.add(t[0])
    else:
      if p[0] in s1:
        s2.add(t[0])
      else:
        s1.add(t[0])
    h.append((t[0],p[0]))

for i in range(1,N+1):
  if i in s1:
    print(0)
  elif i in s2:
    print(1)