module IntSet = Set.Make (struct
  type t = int
  let compare = compare
end)

exception Exit of IntSet.t

let () = Scanf.scanf "%d %d\n" @@ fun n m ->
  let es = Array.make n [] in
  let visited = Array.make n false in
  let trace = Array.make n None in
  for i = 0 to m - 1 do
    Scanf.scanf "%d %d\n" @@ fun a b ->
      es.(a - 1) <- b - 1 :: es.(a - 1)
  done;
  let rec visit vs v =
    match trace.(v) with
    | Some us -> raise (Exit (IntSet.diff vs us))
    | None ->
        if not visited.(v) then begin
          visited.(v) <- true;
          trace.(v) <- Some vs;
          List.iter (fun u -> visit (IntSet.add v vs) u) es.(v);
          trace.(v) <- None
        end in
  try
    for v = 0 to n - 1 do
      visit IntSet.empty v
    done;
    print_endline "-1"
  with Exit vs ->
    Printf.printf "%d\n" (IntSet.cardinal vs);
    IntSet.iter (fun v -> Printf.printf "%d\n" @@ v + 1) vs
