N = gets.to_i
edges = N.times.map{ [] }
$<.each{|s|
  from, to, dst = s.split.map &:to_i
  edges[from-1] << [to-1, dst]
  edges[to-1] << [from-1, dst]
}

visited = [false] * N


st = [[0, 0]]

while !st.empty?
  new_st = []
  st.each{|from, dst|
    next if visited[from]
    visited[from] = dst%2
    edges[from].each{|to, dst1|
      new_st << [to, dst + dst1]
    }
  }
  st = new_st
end

puts visited
