local n = io.read("*n")
local edge = {}
local len = {}
for i = 1, n do
  edge[i] = {}
  len[i] = -1
end
for i = 1, n - 1 do
  local u, v, w = io.read("*n", "*n", "*n")
  edge[u][v], edge[v][u] = w, w
end
len[1] = 0
local tasks = {1}
for i = 1, n do
  local src = tasks[i]
  if not src then break end
  for dst, cost in pairs(edge[src]) do
    if len[dst] < 0 then
      len[dst] = len[src] + cost
      table.insert(tasks, dst)
    end
  end
end
for i = 1, n do
  print(len[i] % 2)
end
