N=int(input())
tree=[[] for i in range(N)]
for i in range(N-1):
  u,v,w=map(int,input().split())
  tree[u-1].append((v-1,w))
  tree[v-1].append((u-1,w))
h=[]
h.append(0)
distance=[-1 for i in range(N)]
distance[0]=0
while h:
  k=h.pop(0)
  for v in tree[k]:
    x=v[0]
    y=v[1]
    if distance[x]==-1:
      distance[x]=distance[k]+y
      h.append(x)
for i in range(N):
  if distance[i]%2==0:
    print(0)
  else:
    print(1) 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) [] tree=[[] for i in range(N)] tree [[] for i in range(N)] for i in range(N-1):
  u,v,w=map(int,input().split())
  tree[u-1].append((v-1,w))
  tree[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 tree[u-1].append((v-1,w)) [u-1].append [u-1] tree u-1 u 1 append (v-1,w) v-1 v 1 w tree[v-1].append((u-1,w)) [v-1].append [v-1] tree v-1 v 1 append (u-1,w) u-1 u 1 w h=[] h [] h.append(0) h.append h append 0 -1 for i in range(N) for i in range(N) i range(N) range N for i in range(N) -1 distance=[-1 for i in range(N)] distance [-1 for i in range(N)] distance[0]=0 distance[0] distance 0 0 while h:
  k=h.pop(0)
  for v in tree[k]:
    x=v[0]
    y=v[1]
    if distance[x]==-1:
      distance[x]=distance[k]+y
      h.append(x) h k=h.pop(0) k h.pop(0) h.pop h pop 0 for v in tree[k]:
    x=v[0]
    y=v[1]
    if distance[x]==-1:
      distance[x]=distance[k]+y
      h.append(x) v tree[k] tree k x=v[0] x v[0] v 0 y=v[1] y v[1] v 1 if distance[x]==-1:
      distance[x]=distance[k]+y
      h.append(x) distance[x]==-1 distance[x] distance x -1 distance[x]=distance[k]+y distance[x] distance x distance[k]+y distance[k] distance k y h.append(x) h.append h append x for i in range(N):
  if distance[i]%2==0:
    print(0)
  else:
    print(1) i range(N) range N if distance[i]%2==0:
    print(0)
  else:
    print(1) distance[i]%2==0 distance[i]%2 distance[i] distance i 2 0 print(0) print 0 print(1) print 1 x=v[0] v[0] x y=v[1] v[1] y w=map(int,input().split()) map(int,input().split()) w u,v,w=map(int,input().split()) map(int,input().split()) u v,w=map(int,input().split()) map(int,input().split()) v tree=[[] for i in range(N)] [[] for i in range(N)] tree k=h.pop(0) h.pop(0) k N=int(input()) int(input()) N h=[] [] h distance=[-1 for i in range(N)] [-1 for i in range(N)] distance
N=int(input())
tree=[[] for i in range(N)]
for i in range(N-1):
  u,v,w=map(int,input().split())
  tree[u-1].append((v-1,w))
  tree[v-1].append((u-1,w))
h=[]
h.append(0)
distance=[-1 for i in range(N)]
distance[0]=0
while h:
  k=h.pop(0)
  for v in tree[k]:
    x=v[0]
    y=v[1]
    if distance[x]==-1:
      distance[x]=distance[k]+y
      h.append(x)
for i in range(N):
  if distance[i]%2==0:
    print(0)
  else:
    print(1)