use std::io::Read;

fn run() {
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();
    let mut it = s.trim().split_whitespace();
    let n: usize = it.next().unwrap().parse().unwrap();
    let m: usize = it.next().unwrap().parse().unwrap();
    let mut g = vec![vec![]; n];
    let mut ig = vec![vec![]; n];
    let mut d = vec![0; n];
    for _ in 0..m {
        let a = it.next().unwrap().parse::<usize>().unwrap() - 1;
        let b = it.next().unwrap().parse::<usize>().unwrap() - 1;
        g[a].push(b);
        ig[b].push(a);
        d[b] += 1;
    }
    let mut del = vec![false; n];
    loop {
        let mut update = false;
        for i in 0..n {
            if del[i] {
                continue;
            }
            let mut go = false;
            for &u in &g[i] {
                if !del[u] {
                    go = true;
                }
            }
            if d[i] == 0 || !go {
                del[i] = true;
                update = true;
                for &u in &g[i] {
                    d[u] -= 1;
                }
            }
        }
        if !update {
            break;
        }
    }
    if del.iter().all(|v| *v) {
        println!("-1");
        return;
    }
    loop {
        let mut update = false;
        for i in 0..n {
            if del[i] {
                continue;
            }
            let mut d = vec![10000; n];
            let mut q = std::collections::VecDeque::new();
            d[i] = 0;
            q.push_back(i);
            let mut s = i;
            let mut t = i;
            'outer: while let Some(v) = q.pop_front() {
                for &u in &g[v] {
                    if del[u] {
                        continue;
                    }
                    if d[u] > d[v] + 1 {
                        d[u] = d[v] + 1;
                        q.push_back(u);
                    } else if d[u] < d[v] {
                        s = u;
                        t = v;
                        break 'outer;
                    }
                }
            }
            let mut dp = vec![vec![]; n];
            dp[s].push(s);
            let mut q = std::collections::VecDeque::new();
            q.push_back(s);
            while let Some(v) = q.pop_front() {
                for &u in &g[v] {
                    if del[u] || d[u] != d[v] + 1 || dp[u].len() > 0 {
                        continue;
                    }
                    let mut a = dp[v].clone();
                    dp[u].append(&mut a);
                    dp[u].push(u);
                    q.push_back(u);
                }
            }
            let mut next = vec![true; n];
            for &v in dp[t].iter() {
                next[v] = false;
            }
            for i in 0..n {
                if !del[i] && next[i] {
                    del[i] = true;
                    update = true;
                }
            }
        }
        if !update {
            break;
        }
    }
    let cnt = del.iter().filter(|p| !**p).count();
    println!("{}", cnt);
    for i in 0..n {
        if !del[i] {
            println!("{}", i + 1);
        }
    }
}

fn main() {
    run();
}


Measured memory_bytes: 15324