N = gets.to_i
paths = Array.new(N + 1) { [] }

(N-1).times.map do
  u, v, w = gets.split.map(&:to_i)
  paths[v] << [u, w]
  paths[u] << [v, w]
end

TO = 0
W = 1

col = Array.new(N + 1, 0)
1.upto(N) do |n|
  paths[n].each do |path|
    if path[W].even?
      col[path[TO]] = col[n]
    else
      col[path[TO]] = col[n] == 1 ? 0 : 1
    end
  end
end

1.upto(N) do |n|
  puts col[n]
end