#include <bits/stdc++.h>
using namespace std;

#define st first
#define nd second
#define pb push_back

typedef long long   ll;
typedef double      db;
typedef long double ldb;

typedef pair <int, int> pii;
typedef pair <ll,  ll>  pll;
typedef pair <ll,  db>  pdb;
typedef pair <ldb, ldb> pldb;

template <typename T>
void   Debug (T begin, T end);
int    si    ();
ll     sl    ();
string ss    (int); 
db     sf    ();
ldb    slf   ();
void   pi    (int, char = '\n');
void   pl    (ll, char = '\n');
void   pf    (db, char = '\n');
void   plf   (ldb, char = '\n');
void   ps    (string, char = '\n');

ll russian(ll, ll, ll);
ll fast_power(ll, ll, ll);
ll slow_power(ll, ll, ll);
ll gcd(ll, ll);
ll lcm(ll, ll);

const int INF  = 1e9;
const ll  LINF = 1e18;

const int N = 1e3 + 7;
vector<int> G[N], V;
int dist[N], vis[N];
int n;

void bfs(int src)
{
    fill(dist + 1, dist + n + 1, INF);
    dist[src] = 0;
    queue<int> Q;
    Q.push(src);

    while (!Q.empty())
    {
        int v = Q.front();
        Q.pop();
        
        int d = dist[v];
        for (int s : G[v])
            if (dist[s] == INF)
                dist[s] = d + 1,
                Q.push(s);
    }
}

int dfs(int v)
{
    vis[v] = 1;
    sort(G[v].begin(), G[v].end(), [v](int a, int b){
        if (dist[v] > dist[a])
        {
            if (dist[v] > dist[b])
                return dist[a] > dist[b];
            return true;
        }
        if (dist[v] > dist[b])
            return false;
        return dist[a] < dist[b];
    });
    for (int s : G[v])
        if (!vis[s])
        {
            if (dist[s] == dist[v] + 1)
            {
                int res = dfs(s);
                if (res == 0)
                    return 0;
                if (res != -1)
                {
                    V.push_back(v);
                    if (res == v)
                        return 0;
                    return res;
                }
            }
        }
        else if (vis[s] == 1)
        {
            V.push_back(v);
            return s;
        }

    vis[v] = 2;
    return -1;
}

int main()
{
    n = si(); int m = si();
    while (m--)
        G[si()].pb(si());

    for (int i = 1; i <= n; ++i)    
    {
        bfs(i);
        fill(vis + 1, vis + n + 1, 0);
        if (dfs(i) == 0)
            break;
    }

    if (V.empty())
        pi(-1);
    else
    {
        pi(V.size());
        for (int v : V)
            pi(v);
    }
    

    return 0;
}

template <typename T>
void Debug(T begin, T end)
{
    printf("\nDEBUG:\n");
    while (begin != end)
        printf("%d ", *begin),
        begin++;
    printf("\n\n");
}

template <typename T>
T scanf_t(string s)
{
    T a;
    scanf(s.c_str(), &a);
    return a;
}

template <typename T>
void printf_t(T a, string s, char end_l)
{
    s.push_back(end_l);
    printf(s.c_str(), a);
}

int si() { return scanf_t<int>("%d"); }
ll sl() { return scanf_t<ll>("%lld"); }
db sf() { return scanf_t<db>("%f"); }
ldb slf() { return scanf_t<ldb>("%Lf"); }

void pi(int a, char end_l) { printf_t<int>(a, "%d", end_l); }
void pl(ll a, char end_l) { printf_t<ll>(a, "%lld", end_l); }
void pf(db a, char end_l) { printf_t<db>(a, "%lf", end_l); }
void plf(ldb a, char end_l) { printf_t<ldb>(a, "%Lf", end_l); }

void ps(string a, char end_l)
{
    string s = "%s";
    s.push_back(end_l);
    printf(s.c_str(), a.c_str());
}

string ss(int NN)
{
    char T[NN];
    scanf("%s", T);
    return (string)T;
}

ll fast_power(ll a, ll k, ll m)
{
    ll r = 1LL;
    while (k)
    {
        if (k & 1LL)
            r = (r * a) % m;
        a = (a * a) % m;
        k >>= 1LL;
    }
    return r;
}

ll slow_power(ll a, ll k, ll m)
{
    ll r = 1LL;
    while (k)
    {
        if (k & 1LL)
            r = russian(r, a, m);
        a = russian(a, a, m);
        k >>= 1LL;
    }
    return r;
}

ll russian(ll a, ll k, ll m)
{
    ll r = 0LL;
    while (k)
    {
        if (k & 1LL)
            r = (r + a) % m;
        a = (a + a) % m;
        k >>= 1LL;
    }
    return r;
}

ll gcd(ll a, ll b)
{
    while (b)
        swap(a %= b, b);
    return a;
}

ll lcm(ll a, ll b)
{
    return a / gcd(a, b) * b;
}


Measured memory_bytes: 384