N, M = gets.chomp.split(" ").map(&:to_i)
V = Hash.new{|h, k| h[k] = Array.new}
M.times{|i|
  a, b = gets.chomp.split(" ").map(&:to_i)
  V[a] << b
}

def dfs
  lst = T[-1]
  V[lst].each{|v|
    if T.include?(v) then
      wk = T.index(v)
      (wk...T.size).each{|i| A << T[i]}
      A.all?{|a| V[a].select{|v| A.include?(v)}.size == 1} ? break : A.clear
    end
    next if C[v]
    T << v
    C[v] = true
    dfs
    T.pop
    break if not A.empty?
  }
end

T = []
A = []
C = Array.new(N + 1, false)
(1..N).each{|n|
  next if C[n]
  C[n] = true
  T << n
  dfs
  T.pop
  break if not A.empty?
}

if A.empty? then
  puts -1
else
  puts A.size
  puts A.join("\n")
end
