local ior = io.input()
local n = ior:read("*n")
local lines = {}
for i = 1, n do lines[i] = {} end
for i = 1, n - 1 do
  local a, b, c = ior:read("*n", "*n", "*n")
  lines[a][b] = c
  lines[b][a] = c
end
local tasks = {1}
local map = {}
map[1] = 0
for i = 2, n do map[i] = -1 end
local tasknum, done = 1, 0
while(done < tasknum) do
  done = done + 1
  local taskidx = tasks[done]
  for k, v in pairs(lines[taskidx]) do
    if(map[k] == -1) then
      map[k] = (map[taskidx] + v) % 2
      table.insert(tasks, k)
      tasknum = tasknum + 1
    end
  end
end
for i = 1, n do
  print(map[i])
end
