n,m = gets.split.map(&:to_i)

bs = []
nodes = {}
(n+m-1).times do
  a,b = gets.split.map(&:to_i)
  nodes[a] ||= []
  nodes[a] << b
  bs << b
end

targets = (1..n).to_a - bs
answers = {targets.first => 0}

until targets.empty?
  next_targets = []
  targets.each do |t|
    children = nodes[t]
    next unless children
    next_targets += children
    children.each do |x|
      answers[x] = t
    end
  end
  targets = next_targets.dup
end

puts answers.to_a.sort_by {|a,b| a}.map {|a,b| b}.join("\n")