N = gets.chomp.to_i

wires = 2.upto(N).map do
  w = gets.chomp.split(' ').map(&:to_i)
  {
    from: w[0] - 1,
    to: w[1] - 1,
    odd?: w[2].odd?
  }
end

points = [0] * N
while true
  changed = false
  wires.each do |w|
    if w[:odd?] && points[w[:from]] == points[w[:to]]
      points[w[:to]] = 1 - points[w[:to]] if points[w[:to]] == 0
      changed = true
    end
  end
  break if changed == false
end

points[0] = 1 if points.inject(0, &:+) == 0
points.each{ |i| puts i }
