N,M = gets.split.map(&:to_i)
G = Array.new(N + 1){ [] }
E = M.times.map{ gets.split.map(&:to_i) }
E.each do |from,to|
  G[from] << to
end

ACTIVE = Array.new(N + 1)
USED = Array.new(N + 1)
SUBGRAPH = Array.new(N + 1)

def active?(v); ACTIVE[v]; end
def activate!(v);  ACTIVE[v] = true; end
def inactivate!(v); ACTIVE[v] = false; end
def used?(v); USED[v]; end
def use!(v); USED[v] = true; end
def subgraph_include?(v); SUBGRAPH[v]; end
def subgraph_init!(vset)
  ACTIVE.fill(false)
  USED.fill(true)
  SUBGRAPH.fill(false)
  vset.each{|v| USED[v] = false; SUBGRAPH[v] = true }
end
  
def cycle_exists?
  (1 .. N).each do |s|
    next if used?(s)
    
    stack = [s]; use!(s)
    cycle = find_cycle(stack)
    return cycle if cycle
  end
  return false
end

def smaller_cycle?(cycle)
  subgraph_init!(cycle)
  
  stack = nil
  smaller_not_found = cycle.each_with_index.none? do |from, i|
    to = (i + 1 == cycle.size ? cycle[0] : cycle[i + 1])
    to_ = G[from].find{|to_| subgraph_include?(to_) && to_ != to }
    stack = [from, to_] if to_
  end
  return false if smaller_not_found

  use!(stack[0])
  use!(stack[1])
  activate!(stack[0])

  find_cycle(stack)
end

def find_cycle(stack)
  until stack.empty?
    u = stack.pop
    
    if active?(u)
      inactivate!(u)
      next
    else
      activate!(u)
      stack << u
    end
    
    G[u].each do |v|
      return stack.select{|r| active?(r) }.drop_while{|r| r != v } if active?(v)
      next if used?(v)
      use!(v)
      stack << v
    end
  end
  false
end

cycle = cycle_exists?
if !cycle
  puts -1
else
  loop do
    smaller = smaller_cycle?(cycle)
    if smaller  
      cycle = smaller
    else
      break
    end
  end
  puts cycle.size
  puts cycle
end
