$m = gets.to_i
$n = gets.to_i
$s = (1..$n).map{gets.split.map(&:to_i)}

def solve(a)
  if a.size == $m
    return a
  end
  $s.select{|e|a.include?(e[1])&& !a.include?(e[0])}.map{|e|
    solve(a + [e[0]])
  }.shuffle[0]
end

p solve([2])