import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.string;

void main() {
    auto s = readln.split.map!(to!int);
    auto N = s[0];
    auto M = s[1];
    auto G = new int[][](N);
    foreach (_; 0..M) {
        s = readln.split.map!(to!int);
        G[s[0]-1] ~= s[1] - 1;
    }


    DList!(Tuple!(int, int)) que;
    int bestv = 101010;
    int[] ansans;

    foreach (i; 0..N) {
        que.clear;
        que.insertBack(tuple(i, -1));

        bool[int] used;
        auto prev = new int[](N);
        prev[] = -1;

        while (!que.empty) {
            auto n = que.front[0];
            auto p = que.front[1];
            que.removeFront;
            if (n in used && n != i) continue;
            prev[n] = p;
            if (n in used && n == i) {
                int[] ans;
                for (int v = n, flag = 0; v != n || flag == 0; flag = 1) {
                    ans ~= v;
                    v = prev[v];
                }
                if (ans.length < bestv) {
                    bestv = ans.length.to!int;
                    ansans = ans.dup;
                }
                break;
            }
            used[n] = true;
            foreach (m; G[n]) {
                que.insertBack(tuple(m, n));
            }
        }
    }

    if (bestv == 101010)
        writeln(-1);
    else {
        ansans.length.writeln;
        ansans.each!(a => writeln(a + 1));
    }
}
