N = gets.to_i

graph = Hash.new { |h, k| h[k] = {} }

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

queue = [[1, 0]]
path = {}
colors = Array.new(N)

until queue.empty?
  v, dist = queue.shift

  if dist.even?
    colors[v - 1] = 0
  else
    colors[v - 1] = 1
  end

  next if path[v]
  path[v] = true

  graph[v].each do |n, w|
    queue << [n, dist + w]
  end
end

puts colors