n = gets.chomp.to_i
uvw = []
(n-1).times do
  uvw.push gets.split.map(&:to_i)
end
$d = []
$d[1] = 0
$h = Hash.new([])
uvw.each do |e|
  u = e[0]
  v = e[1]
  w = e[2]
  $h[u] += [[v, w]]
  $h[v] += [[u, w]]
end
$color = []
$color[1] = 0
def dfs(u)
  $h[u].each do |e|
    v = e.first
    next if $d[v]

    $d[v] = $d[u] + e.last
    if $d[v].even?
      $color[v] = 0
    else
      $color[v] = 1
    end
    dfs(v)
  end
end
dfs(1)
puts $color[1..n]
