n, m = gets.split.map(&:to_i)
parents = {}
(n + m - 1).times do |i|
  parent, child = gets.split.map(&:to_i)
  if parents[child]
    parents[child].push parent
  else
    parents[child] = [ parent ]
  end
end

root = nil
n.times do |i|
  tmp = i + 1
  unless parents[tmp]
    root = tmp
    break
  end
end
parent_hash = {}
parent_hash[root] = 0
targets = [ root ]
others = parents.keys

while others.length > 0
  next_targets = []
  next_others = []
  others.each do |o|
    if parents[o].length == 1 && targets.include?(parents[o][0])
      parent_hash[o] = parents[o][0]
      next_targets.push o
    else
      parents[o].delete_if { |op| targets.include? op }
      next_others.push o
    end
  end
  targets = next_targets
  others = next_others
end

n.times do |i|
  tmp = i + 1
  puts parent_hash[tmp]
end

