local List = {}
function List.new ()
    return {first = 0, last = -1}
end

function List.pushleft (list, value)
    local first = list.first - 1
    list.first = first
    list[first] = value
end

function List.pushright (list, value)
    local last = list.last + 1
    list.last = last
    list[last] = value
end

function List.popleft (list)
    local first = list.first
    local value = list[first]
    list[first] = nil
    list.first = first + 1
    return value
end

function List.popright (list)
    local last = list.last
    local value = list[last]
    list[last] = nil
    list.last = last - 1
    return value
end

function List.empty (list)
    return list.first > list.last
end

----------

local n=io.read("n")
local graph={}
for i=1,n do
    graph[i]={}
end
for i=1,n-1 do
    local u,v,w=io.read("n","n","n")
    w=w%2
    graph[u][v]=w
    graph[v][u]=w
end

local stack=List.new()
List.pushright(stack,{1,0})
local checked={true}
local color={1}

while not List.empty(stack) do
    local pop=List.popright(stack)
    local u=pop[1]
    local w=pop[2]
    for v,_ in pairs(graph[u]) do
        local nw=w+graph[u][v]
        if not checked[v] then
            if nw%2==0 then
                color[v]=1
            else
                color[v]=0
            end
            checked[v]=true
            List.pushright(stack,{v,nw})
        end
    end
end

for i=1,n do
    print(color[i])
end