n = gets.chomp.to_i
dist = {}
(n - 1).times do |i|
  u, v, w = gets.chomp.split(" ").map(&:to_i)
  dist[u] ||= {}
  dist[u][v] = w
  dist[v] ||= {}
  dist[v][u] = w
end

require "set"

def distance(dist, src, dst, d = [], visit = Set.new)
  return [] if !dist.key?(src)
  visit << src
  if dist[src].key?(dst)
    return d.push(dist[src][dst])
  end
  dist[src].each do |k, v|
    next if visit.include?(k)
    dd = distance(dist, k, dst, d.push(v), visit)
    return dd unless dd.empty?
  end
end

res = []
res << "0"
2.upto(n) do |i|
  dd = distance(dist, 1, i).inject(&:+)
  if (dd % 2 == 0)
    res << "0"
  else
    res << "1"
  end
end
puts res.join("\n")
