local n, m = io.read("*n", "*n")
local edge_c, edge_p_cnt = {}, {}
local p = {}
for i = 1, n do
  edge_c[i] = {}
  edge_p_cnt[i] = 0
  p[i] = 0
end
for i = 1, n + m - 1 do
  local a, b = io.read("*n", "*n")
  table.insert(edge_c[a], b)
  edge_p_cnt[b] = edge_p_cnt[b] + 1
end

local tasks = {}
for i = 1, n do
  if edge_p_cnt[i] == 0 then
    p[i] = 0
    table.insert(tasks, i)
  end
end

while 0 < #tasks do
  local src = tasks[#tasks]
  table.remove(tasks)
  for i = 1, #edge_c[src] do
    local dst = edge_c[src][i]
    edge_p_cnt[dst] = edge_p_cnt[dst] - 1
    if edge_p_cnt[dst] == 0 then
      p[dst] = src
      table.insert(tasks, dst)
    end
  end
end
for i = 1, n do
  print(p[i])
end
