#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define ins insert
#define sb substr
#define con continue
#define ub upper_bound
#define lb lower_bound
#define sp fixed<<setprecision
#define bp __builtin_popcountll
#define pll pair<ll,ll>
#define pld pair<ld,ld>
using namespace std;

ll power(ll x, ll y);
ll mpower(ll x, ll y, ll p);
ll modInv(ll a, ll m);
ll gcdExtended(ll a, ll b, ll *x, ll *y);
bool isPrime(ll n);

vector<ll> A[1001];
ll vis[1001],cvis[1001],par[1001],lvl[1001],pp=1e8,ff=0;

vector<ll> v;

void DFS(ll x){
    vis[x]=1;
    cvis[x]=1;
    for(int i=0;i<A[x].size();i++){
        if(!vis[A[x][i]]){
            lvl[A[x][i]]=lvl[x]+1;
            DFS(A[x][i]);
        }
        else{
            if(cvis[A[x][i]]){
                pp=min(pp,lvl[x]-lvl[A[x][i]]+1);
            }
        }
    }
    cvis[x]=0;
}

void DFS2(ll x){
    if(ff){
        return;
    }
    vis[x]=1;
    cvis[x]=1;
    for(int i=0;i<A[x].size();i++){
        if(!vis[A[x][i]]){
            par[A[x][i]]=x;
            lvl[A[x][i]]=lvl[x]+1;
            DFS2(A[x][i]);
        }
        else{
            if(cvis[A[x][i]]){
                ff=1;
                ll y=lvl[x]-lvl[A[x][i]]+1;
                if(y==pp){
                    v.pb(A[x][i]);
                    y=x;
                    while(y!=A[x][i]){
                        v.pb(y);
                        y=par[y];
                    }
                    return;
                }
            }
        }
    }
    cvis[x]=0;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t,i,j,k,l,h,p,q,r,x,y,z,a,b,c,d,f,n,m,M=1000000007;
    char ch,ch2,ch3;
    string s,s1,s2,s3;
    vector<ll> w;
    unordered_map<ll,ll> N;
    set<ll> S;
    set<ll> :: iterator itr;
    cin>>n>>m;
    for(i=0;i<m;i++){
        cin>>x>>y;
        A[x].pb(y);
    }
    for(i=1;i<=n;i++){
        for(j=1;j<=n;j++){
            vis[j]=0;
            lvl[j]=0;
        }
        DFS(i);
    }
    if(pp>n){
        cout<<-1;
        return 0;
    }
    for(i=1;i<=n && ff==0;i++){
        for(j=1;j<=n;j++){
            vis[j]=0;
            lvl[j]=0;
        }
        DFS2(i);
    }
    cout<<v.size()<<"\n";
    for(i=0;i<v.size();i++){
        cout<<v[i]<<"\n";
    }
    return 0;
}

ll modInv(ll a, ll m){
    ll x, y;
    ll g = gcdExtended(a, m, &x, &y);
    ll res = (x%m + m) % m;
    return res;
}

ll gcdExtended(ll a, ll b, ll *x, ll *y){
    if (a == 0){
        *x = 0, *y = 1;
        return b;
    }
    ll x1, y1;
    ll gcd = gcdExtended(b%a, a, &x1, &y1);
    *x = y1 - (b/a) * x1;
    *y = x1;
    return gcd;
}

ll mpower(ll x, ll y, ll p){
    ll res = 1;
    x = x % p;
    while(y > 0){
        if(y & 1) res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}

ll power(ll x, ll y){
    ll res = 1;
    while (y > 0){
        if (y & 1) res = res*x;
        y = y>>1;
        x = x*x;
    }
    return res;
}

bool isPrime(ll n){
    if (n <= 1)  return false;
    if (n <= 3)  return true;
    if (n%2 == 0 || n%3 == 0) return false;
    ll p=sqrt(n);
    for(int i=5;i<=p;i=i+6)
        if (n%i == 0 || n%(i+2) == 0)
            return false;
    return true;
}


Measured memory_bytes: 384