def restore_tree(graph_hash,n)
  next_root = ((1..n).to_a - graph_hash.keys)[0]
  graph_hash[next_root] = [0]
  while(graph_hash.values.flatten.length > n)
    tmp_next_root = 0
    graph_hash.each do |k,v|
      graph_hash[k] = v - [next_root] if v.length >= 2
      tmp_next_root = k if v == [next_root]
    end
    next_root = tmp_next_root
  end
  graph_hash
end
input = readlines
n = input[0].chomp.split(' ')[0].to_i
m = input[0].chomp.split(' ')[1].to_i
graph_hash = {}
(1..n - 1 + m).each do |i|
  graph_hash[input[i].chomp.split(' ')[1].to_i] = [] unless graph_hash[input[i].chomp.split(' ')[1].to_i]  
  graph_hash[input[i].chomp.split(' ')[1].to_i] << input[i].chomp.split(' ')[0].to_i
end
original_graph_hash = restore_tree(graph_hash,n)
(1..n).each do |i|
  puts original_graph_hash[i][0]
end
