#include <bits/stdc++.h>

using namespace std;
#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define _dec(i,N,j) for(int i = (N-1);i >= (j);i--)
#define _rec(i,N,j) for(int i = (N);i >=(j);i--)
#define ALL(x) x.begin(),x.end()
#define MEM(a,n) memset(a,n,sizeof(a))
#define fst first
#define scd second
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

int get_int(){int x;scanf("%d",&x);return x;}
LL get_ll(){LL x;scanf("%lld",&x);return x;}
double get_db(){double x;scanf("%lf",&x);return x;}

template<typename T> int chmin(T &a,T b){if(a > b){a = b;return 1;}else return 0;}
template<typename T> int chmax(T &a,T b){if(a < b){a = b;return 1;}else return 0;}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {_for(i,0,v.size()) os << v[i] << " ";return os;}
template<typename T>
ostream& operator<<(ostream& os,const set<T>& v){for(auto a:v) os << a <<" ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& v){os << v.fst <<" "<<v.scd << " ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const map<T1,T2>& v){for(auto a:v) cout << a << endl;return os;}

static const int dx[8] = { -1,  0, 1, 0,  1, -1,  1, -1};
static const int dy[8] = {0,  1, 0,  -1,  1, -1, -1,  1};
const double pi  = acos(-1.0);
const double eps = 1e-8;
const LL  INF  = 0x3f3f3f3f3f3f3f3f;
const int inf  = 0x3f3f3f3f;

const int maxn = 1e3+5;

bool Gc[maxn][maxn];
int vis[maxn];
vector<int> G[maxn];

vector<int> ans;
unordered_set<int> valid;


int N,M;

bool can_do(int v){return valid.count(v);}
void dfs(int v,vector<int> &s);

bool check_ok(vector<int> &s){
    int e = 0;
    int sz = s.size();
    //cout << s << endl;
    _for(i,0,sz){
        int a = s[i];
        _for(j,i+1,sz){
            int b = s[j];
            if(Gc[a][b]) ++e;
            if(Gc[b][a]) ++e;
        }
    }
   // cout << e<<" "<<sz << endl;
    return (e==sz);

}

void resolve(vector<int> &s,int v){
    int bac = s.size() - 1;
    vector<int> nex;
    while(s[bac] != v){
        nex.PB(s[bac--]);
    }
    nex.PB(v);

    //cout << nex << endl;

    if(check_ok(nex)){
        ans = nex;
        return;
    }
    valid.clear();
    int sz = nex.size();

    _for(i,0,sz){
        valid.insert(nex[i]);
    }
    MEM(vis,0);
    map<int,int> link;
    _for(i,0,sz){
        int bef = nex[i];
        int af = nex[(i+1)%sz];
        link[bef] = af;
    }

    _for(i,0,sz){
        int w = nex[i];
        for(auto a:G[w]){
            if(can_do(a)){
                if(link[w] != a && link[a] != w){
                    vis[w] = -1;
                    vector<int> temp;temp.PB(w);temp.PB(a);

                    dfs(a,temp);
                    return;
                }
            }

        }

    }

}


void dfs(int v,vector<int> &s){
    vis[v] = -1;
    for(auto a:G[v]){
        if( can_do(a) && vis[a] != 1){
            if(vis[a] == -1){
                resolve(s,a);
                return;
            }
            s.PB(a);
            dfs(a,s);
            s.pop_back();
        }
    }
    vis[v] = 1;
}


int main()
{
    MEM(Gc,0);

    cin >> N >> M;
    _for(i,0,M){
        int s , v;
        cin >> s >> v;
        Gc[s][v] = 1;
        G[s].PB(v);
    }

    _rep(i,1,N) valid.insert(i);

    _rep(st,1,N){
        if(!vis[st]){
            vector<int> k;
            k.PB(st);
            dfs(st,k);
            if(ans.size()) break;
        }
    }


    if(ans.size()){
        cout << ans.size() << endl;
        _for(i,0,ans.size()){
            cout << ans[i] << endl;
        }
    }else cout << -1 << endl;



    return 0;
}


Measured memory_bytes: 1792