    import core.bitop, std.bitmanip;
    import core.checkedint;
    import std.algorithm, std.functional;
    import std.array, std.container;
    import std.bigint;
    import std.conv;
    import std.math, std.numeric;
    import std.range, std.range.interfaces;
    import std.stdio, std.string;
    import std.typecons;
     
    void main()
    {
        int n, m;
        readf("%s %s", &n, &m);
        readln;
     
        auto g = new int[][] (n+1);
        
        foreach (_; 0 .. m) {
            int u, v;
            readf("%s %s", &u, &v);
            readln;
            
            g[u] ~= v;
        }
        
        auto tin = new int[] (n+1);
        auto tout = new int[] (n+1);
        tin[] = tout[] = 0;
        
        auto ans = make!(DList!int);
        
        int tm = 0;
        bool go(int v) { 
            tin[v] = ++tm;
            ans ~= v;
            
            int ret = 0;
            foreach (u; g[v]) {
                if (tout[u] == 0 && tin[u] != 0 && tin[u] < tin[v] 
                        && (ret == 0 || tin[u] > tin[ret])) {
                    ret = u;
                }
            }
            if (ret != 0) {
                debug { writeln(ans.array.map!(to!string).join(' ')); }
                
                while (ans.front != ret) { ans.removeFront(); }
                return true;
            }
            
            foreach (u; g[v]) {
                if (tout[u] > 0) { continue; }
                
                if (go(u)) { return true; }
            }
            
            tout[v] = ++tm;
            ans.removeBack();
            
            return false;
        }
        
        foreach (i; 1 .. n+1) {
            if (tin[i] > 0) { continue; }
            
            if (go(i)) {
                debug { writeln(ans.array.map!(to!string).join(' ')); }
                
                int v = ans.front;
                ans.removeFront();
                foreach (u; g[v]) {
                    while (tin[u] > tin[ans.front]) { ans.removeFront(); }
                }
                
                ans.insertFront(v);
                
                int len = 0;
                foreach (_; ans) { ++len; }
                len.writeln;
                ans.each!writeln;
                
                return;
            }
        }
        
        writeln(-1);
    }