use std::collections::{BTreeSet, VecDeque};

fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let n: usize = sc.read();
    let m: usize = sc.read();
    let mut graph = vec![vec![]; n];
    for _ in 0..m {
        let a = sc.read::<usize>() - 1;
        let b = sc.read::<usize>() - 1;
        graph[a].push(b);
    }

    let mut ans = vec![];
    for i in 0..n {
        let result = bfs(i, &graph);
        //        eprintln!("{} {:?}", i, result);
        if !result.is_empty() && (ans.is_empty() || result.len() < ans.len()) {
            ans = result;
        }
    }
    //    validate(&ans, &graph);

    if ans.is_empty() {
        sc.write("-1\n");
    } else {
        sc.write(format!("{}\n", ans.len()));
        for ans in ans.into_iter() {
            sc.write(format!("{}\n", ans + 1));
        }
    }
}

fn validate(ans: &Vec<usize>, graph: &Vec<Vec<usize>>) {
    let n = graph.len();
    let set = ans.iter().cloned().collect::<BTreeSet<_>>();
    let mut into = vec![0; n];
    let mut out = vec![0; n];
    let mut count = 0;
    for (i, to) in graph.iter().enumerate() {
        for &j in to.iter() {
            if set.contains(&i) & set.contains(&j) {
                out[i] += 1;
                into[j] += 1;
            }
        }
    }
    assert_eq!(out, into, "{:?}", set);
}

fn bfs(start: usize, graph: &Vec<Vec<usize>>) -> Vec<usize> {
    let n = graph.len();
    let mut q = VecDeque::new();
    q.push_back(start);
    let mut dist = vec![n; n];
    dist[start] = 0;
    let mut prev = vec![n; n];
    prev[start] = start;
    while let Some(v) = q.pop_front() {
        for &next in graph[v].iter() {
            if dist[next] > dist[v] + 1 {
                q.push_back(next);
                dist[next] = dist[v] + 1;
                prev[next] = v;
            } else if next == start {
                let mut a = vec![next];
                let mut cur = v;
                while cur != start {
                    a.push(cur);
                    cur = prev[cur];
                }
                return a;
            }
        }
    }
    //    eprintln!("{:?}", dist);
    Vec::new()
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: std::ops::Deref<Target = str>>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 4476