local DBG = true
local function dbgpr(...)
    if DBG then
        io.write("[dbg]")
        print(...)
    end
end

local function dbgpr_t(tbl, use_pairs)
    if DBG then
        local enum = ipairs
        if use_pairs then
            enum = pairs
        end
        dbgpr(tbl)
        io.write("[dbg]")
        for i,v in enum(tbl) do
            io.write(i)
            io.write(":")
            io.write(tostring(v))
            io.write(" ")
        end
        print("")
    end
end

local function use_strict()
    local mt = {
        __index = function(t,k) error("_G __index:" .. k) end,
        __newindex = function(t,k,v) error("_G __newindex:" .. k) end
    }
    setmetatable(_G, mt)
end

-- http://www.lua.org/pil/11.4.html
List = {}
function List.new()
    return setmetatable({first = 0, last = -1}, {__index = List})
end

--[[
function List:pushleft(value)
    local first = self.first - 1
    self.first = first
    self[first] = value
end
]]

function List:pushright(value)
    local last = self.last + 1
    self.last = last
    self[last] = value
end

function List:popleft()
    local first = self.first
    if first > self.last then error("list is empty") end
    local value = self[first]
    self[first] = nil        -- to allow garbage collection
    self.first = first + 1
    return value
end

--[[
function List:popright()
    local last = self.last
    if self.first > last then error("list is empty") end
    local value = self[last]
    self[last] = nil         -- to allow garbage collection
    self.last = last - 1
    return value
end
]]

function List:count()
    return self.last - self.first + 1
end
--
use_strict()
local N = io.read("n")
local weights = {}
local adj_list = {}
for i=1,N do
    adj_list[i] = {}
end
local function key(u,v)
    return u .. "," .. v
end
local function getw(u,v)
    return weights[key(u,v)] or weights[key(v,u)]
end
for i=1,N-1 do
    local u,v,w = io.read("n", "n", "n")
    weights[key(u,v)] = w
    table.insert(adj_list[u], v)
    table.insert(adj_list[v], u)
end

local distance_from_1 = {}
distance_from_1[1] = 0
do
    local seen = {}
    seen[1] = true
    local accum = 0
    local q = List.new()
    q:pushright(1)
    local count = 1
    while count < N do
        local from = q:popleft()
        local w_before = distance_from_1[from]
        for _, to in ipairs(adj_list[from]) do
            if not seen[to] then
                seen[to] = true
                local w = getw(from, to)
                distance_from_1[to] = w_before + w
                count = count + 1
                q:pushright(to)
            end
        end
    end
end
--dbgpr_t(distance_from_1)
for i=1,N do
    if distance_from_1[i] % 2 == 0 then
        print(0)
    else
        print(1)
    end
end