import java.io._
import java.util.StringTokenizer
import scala.util.control.Breaks.{breakable,break}
import scala.collection.mutable.{Map, Queue, PriorityQueue}

object Main extends App {
  val in = new InputReader(System.in)
  val pw = new PrintWriter(System.out)

  val N, M = in.next().toInt
  val graph = Array.fill[List[Int]](N+1)(Nil)
  for (_ <- 1 to M) {
    val a, b = in.next().toInt
    graph(a) = b :: graph(a)
  }

  def mkAns(now: Int, lst: List[Int]): List[Int] = {
    lst match {
      case a :: rest =>
        if (a == now)
          List(a)
        else
          a :: mkAns(now, rest)
    }
  }

  //
  val done = new Array[Boolean](N+1)
  var ans: List[Int] = Nil
  breakable {
    for (i <- 1 to N) {
      if (!done(i)) {
        done(i) = true

        val q = new Queue[(Int, List[Int])]
        //val dp = new Array[Boolean](N+1)
        //dp(i) = true
        q.enqueue((i, List()))

        breakable {
          while (!q.isEmpty) {
            val (now, alr) = q.dequeue()
            if (!done(now))
              done(now) = true

            if (alr.contains(now)) {
              ans = mkAns(now, alr)
              break
            }
            else {
              for (e <- graph(now))
                q.enqueue((e, now :: alr))
            }
          }
        }
      }

      if (ans != Nil)
        break
    }
  }

  if (ans == Nil)
    pw.println(-1)
  else {
    pw.println(ans.length)
    ans.foreach { x => pw.println(x) }
  }
  pw.flush()
}


class InputReader(stream: InputStream) {
  private val reader = new BufferedReader(new InputStreamReader(stream))
  private var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())
  def next(): String = {
    while (!tokenizer.hasMoreTokens()) {
      tokenizer = new StringTokenizer(reader.readLine())
    }
    tokenizer.nextToken()
  }
}
