(N, M), *ABs = readlines.map{|l| l.split.map(&:to_i)}

@g, @f = Hash.new{|h, k| h[k] = []}, Hash.new{|h, k| h[k] = []}
ABs.each{|a, b| @g[a] << b; @f[b] << a}

def bfs(a)
  q, p = [a], []
  until q.empty?
    b = q.shift
    @g[b].select{|x| p[x].nil?}.each do |c|
      p[c] = b
      q << c
    end
  end
  p
end

res, len = nil, N + 1
(1 .. N).each do |a|
  p = bfs(a)
  @f[a].each do |b|
    next unless p[b]
    r = [b]
    r.unshift(p[r[0]]) until r[0] == a
    l = r.size
    res, len = r, l if l < len
  end
end  
puts res.nil? ? -1 : len, res