n, m = gets.split.map(&:to_i)
graph = Array.new(n) { Array.new }
m.times do
  a, b = gets.split.map(&:to_i)
  graph[a - 1] << b - 1
end
rest = (0...n).to_a
options = []
until rest.empty?
  num = rest.shift
  queue = [[num, []]]
  until queue.empty?
    current, visited = queue.shift
    graph[current].each do |dest|
      visited_n = visited.dup
      visited_n << current
      if visited_n.include?(dest)
        if (visited_n & graph[current]).length == 1
          puts visited_n.size
          visited_n.each do |v|
            puts v + 1
          end
          exit
        end
      else
        queue << [dest, visited_n]
      end
    end
  end
end
puts -1
