tree = Hash.new { |h, k| h[k] = {} }
n = gets.to_i
(n - 1).times do
  u, v, w = gets.split.map(&:to_i)
  tree[u - 1][v - 1] = w # 0-origin
end

# colors <0, 1>
cs = Array.new(n, 0)
cs[0] = 1

tree.each do |i0, h|
  c = cs[i0]
  h.each do |i1, d|
    cs[i1] = c if d.even?
  end
end

p *cs
