n, m = gets.split.map(&:to_i)
child = Hash.new { |h, k| h[k] = [] }
parent = Hash.new { |h, k| h[k] = [] }
(n + m - 1).times do
  a, b = gets.split.map(&:to_i)
  child[a] << b
  parent[b] << a
end

root = 1
until parent[root].empty?
  root = parent[root].first
end

queue = [root]
visited = {}
deleted = 0
until queue.empty?
  pos = queue.shift
  child[pos].each do |ch|
    if visited[ch] && parent[ch].size > 1
      parent[ch].delete(visited[ch])
      deleted += 1
      if deleted == m
        break
      end
    end
    visited[ch] = pos
    queue << ch
  end
  if deleted == m
    break
  end
end

(1..n).each do |i|
  puts(parent[i].first || 0)
end
