n=gets.to_i

edges=Array.new(n){Array.new}
weight={}
ans=Array.new(n)
done=Array.new(n,false)
ans[0]=0
done[0]=true

(n-1).times{
  u,v,w=gets.split.map(&:to_i)
  u-=1
  v-=1
  edges[u]<<v
  edges[v]<<u
  weight[[u,v]]=weight[[v,u]]=w%2
}

q=[0]
until q.empty?
  u=q.shift
  edges[u].each{|v|
    next if done[v]
    done[v]=true
    ans[v]=(ans[u]+weight[[u,v]])%2
    q << v
  }
end

puts ans