N = int(input())
e = [[] for _ in range(N)]
for _ in range(N-1):
  u,v,w = map(int, input().split())
  u -= 1
  v -= 1
  e[u].append((v,w))
  e[v].append((u,w))

res = [-1]*N
res[0] = 0
q = [0]
while len(q):
  v = q.pop()
  for u,w in e[v]:
    if res[u]>=0:
      continue
    res[u] = res[v]+w
    q.append(u)

for r in res:
  print(r%2) N = int(input()) N int(input()) int input() input [] for _ in range(N) for _ in range(N) _ range(N) range N for _ in range(N) [] e = [[] for _ in range(N)] e [[] for _ in range(N)] for _ in range(N-1):
  u,v,w = map(int, input().split())
  u -= 1
  v -= 1
  e[u].append((v,w))
  e[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 u -= 1 u 1 v -= 1 v 1 e[u].append((v,w)) [u].append [u] e u append (v,w) v w e[v].append((u,w)) [v].append [v] e v append (u,w) u w res = [-1]*N res [-1]*N [-1] -1 N res[0] = 0 res[0] res 0 0 q = [0] q [0] 0 while len(q):
  v = q.pop()
  for u,w in e[v]:
    if res[u]>=0:
      continue
    res[u] = res[v]+w
    q.append(u) len(q) len q v = q.pop() v q.pop() q.pop q pop for u,w in e[v]:
    if res[u]>=0:
      continue
    res[u] = res[v]+w
    q.append(u) u w e[v] e v if res[u]>=0:
      continue
     res[u]>=0 res[u] res u 0 continue res[u] = res[v]+w res[u] res u res[v]+w res[v] res v w q.append(u) q.append q append u for r in res:
  print(r%2) r res print(r%2) print r%2 r 2 N = int(input()) int(input()) N w = map(int, input().split()) map(int, input().split()) w res = [-1]*N [-1]*N res v = q.pop() q.pop() v u,v,w = map(int, input().split()) map(int, input().split()) u q = [0] [0] q v,w = map(int, input().split()) map(int, input().split()) v v -= 1 1 v e = [[] for _ in range(N)] [[] for _ in range(N)] e u -= 1 1 u
N = int(input())
e = [[] for _ in range(N)]
for _ in range(N-1):
  u,v,w = map(int, input().split())
  u -= 1
  v -= 1
  e[u].append((v,w))
  e[v].append((u,w))

res = [-1]*N
res[0] = 0
q = [0]
while len(q):
  v = q.pop()
  for u,w in e[v]:
    if res[u]>=0:
      continue
    res[u] = res[v]+w
    q.append(u)

for r in res:
  print(r%2)