N = gets.to_i
S = []
(N - 1).times{|i|
  u, v, w = gets.chomp.split(" ").map(&:to_i);
  S << (w.even? ? [u, v, 1] : [u, v, -1])
}

vtx = Array.new(N + 1, 0)
vtx[1] = 1
while(vtx.count{|v| v == 0} > 1) do
  (1..N).each{|i|
    next if vtx[i] == 0
    S.select{|s| s[0] == i && vtx[s[1]] == 0}.each{|s| vtx[s[1]] = vtx[i] * s[2]}
    S.select{|s| s[1] == i && vtx[s[0]] == 0}.each{|s| vtx[s[0]] = vtx[i] * s[2]}
  }
end

(1..N).each{|i|
  puts vtx[i] == 1 ? '1' : '0'
}
