N=int(input())
links=[set() for _ in [0]*N]
for i in range(1,N):
  u,v,w=map(int,input().split())
  u-=1
  v-=1
  links[u].add((v,w))
  links[v].add((u,w))
ans=[-1]*N
q=[(0,0,-1)]
while q:
  v,d,p=q.pop()
  if d%2==0:
    ans[v]=0
  else:
    ans[v]=1
  for u,w in links[v]:
    if u==p:
      continue
    q.append((u,w+d,v))
print('\n'.join(map(str,ans))) N=int(input()) N int(input()) int input() input set() for _ in [0]*N for _ in [0]*N _ [0]*N [0] 0 N for _ in [0]*N set() set links=[set() for _ in [0]*N] links [set() for _ in [0]*N] for i in range(1,N):
  u,v,w=map(int,input().split())
  u-=1
  v-=1
  links[u].add((v,w))
  links[v].add((u,w)) i range(1,N) range 1 N 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 links[u].add((v,w)) [u].add [u] links u add (v,w) v w links[v].add((u,w)) [v].add [v] links v add (u,w) u w ans=[-1]*N ans [-1]*N [-1] -1 N q=[(0,0,-1)] q [(0,0,-1)] (0,0,-1) 0 0 -1 while q:
  v,d,p=q.pop()
  if d%2==0:
    ans[v]=0
  else:
    ans[v]=1
  for u,w in links[v]:
    if u==p:
      continue
    q.append((u,w+d,v)) q v,d,p=q.pop() v q.pop() q.pop q pop d p if d%2==0:
    ans[v]=0
  else:
    ans[v]=1
   d%2==0 d%2 d 2 0 ans[v]=0 ans[v] ans v 0 ans[v]=1 ans[v] ans v 1 for u,w in links[v]:
    if u==p:
      continue
    q.append((u,w+d,v)) u w links[v] links v if u==p:
      continue
     u==p u p continue q.append((u,w+d,v)) q.append q append (u,w+d,v) u w+d w d v print('\n'.join(map(str,ans))) print '\n'.join(map(str,ans)) '\n'.join '\n' join map(str,ans) map str ans u,v,w=map(int,input().split()) map(int,input().split()) u w=map(int,input().split()) map(int,input().split()) w ans=[-1]*N [-1]*N ans d,p=q.pop() q.pop() d v,d,p=q.pop() q.pop() v u-=1 1 u q=[(0,0,-1)] [(0,0,-1)] q p=q.pop() q.pop() p links=[set() for _ in [0]*N] [set() for _ in [0]*N] links N=int(input()) int(input()) N v,w=map(int,input().split()) map(int,input().split()) v v-=1 1 v
N=int(input())
links=[set() for _ in [0]*N]
for i in range(1,N):
  u,v,w=map(int,input().split())
  u-=1
  v-=1
  links[u].add((v,w))
  links[v].add((u,w))
ans=[-1]*N
q=[(0,0,-1)]
while q:
  v,d,p=q.pop()
  if d%2==0:
    ans[v]=0
  else:
    ans[v]=1
  for u,w in links[v]:
    if u==p:
      continue
    q.append((u,w+d,v))
print('\n'.join(map(str,ans)))