# input
n = gets.chomp.to_i
graph = Array.new(n+1){[]}
color = Array.new(n+1, -1)

(n-1).times do
  u, v, w = gets.chomp.split.map(&:to_i)
  graph[u].push([v, w])
  graph[v].push([u, w])
end  

# main
que = [1]
color[1] = 0
while not que.empty? do
  nver = que.shift
  ncol = color[nver]
  
  graph[nver].each do |v|
    if color[v[0]] == -1 then
      que.push(v[0])
    end
    if v[1].odd? then
      color[v[0]] = 1 - ncol
    else
      color[v[0]] = ncol
    end
  end
end
  
# output
(1..n).each do |i|
  puts color[i]
end
  