n = gets.chomp.to_i
a = []
color = Array.new(n,0)
for i in 1..n-1 do
    a = gets.chomp.split(" ").map(&:to_i)
    u = a[0]
    v = a[1]
    w = a[2]
    if w.odd? 
        if color[u-1] != 0
             color[v-1] = color[u-1] * -1
        elsif color[v-1] != 0
             color[u-1] = color[v-1] * -1
        else
            color[u-1] = 1
            color[v-1] = -1
        end
    else
        if color[u-1] != 0
             color[v-1] = color[u-1]
        elsif color[v-1] != 0
             color[u-1] = color[v-1]
        end
    end
end

for i in 1..n do
    if color[i-1] >= 0
        puts "0"
    else
        puts "1"
    end
end
