#include <iostream>
#ifdef MBP
#include "stdc++.h"
#else
#include <bits/stdc++.h>
#endif

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define REP(i, n) for (long long int i = 0, i##_len = (n); i < i##_len; ++i)
#define REP_R(i, n) for (long long int i = (n - 1); i >= 0; --i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((long long int)(x).size())
#define BIT(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());

#define INF INT_MAX
#define INFLL LLONG_MAX
#define PB push_back
#define MOD 1000000007LL
#define LSB(x) __builtin_ctzll(x)
#define MSB(x) 64LL - __builtin_clzll(x) - 1LL
#define MSBINT(x) 32LL - __builtin_clz(x)
#define BITCNT(x) __builtin_popcountll(x)

using namespace std;
using uif = uint_fast64_t;
using ll = long long int;
using vec = vector<ll>;
using mat = vector<vector<ll>>;
using pa = pair<ll, ll>;
using tTree = __gnu_pbds::tree<ll, __gnu_pbds::null_type, less<ll>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;

template <class T>
using PQ = priority_queue<T>;
template <class T>
using PQG = priority_queue<T, vector<T>, greater<T>>;

const ll dx[4] = {1, 0, -1, 0};
const ll dy[4] = {0, 1, 0, -1};
const ll dx8[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy8[8] = {0, 1, 1, 1, 0, -1, -1, -1};

template <class T>
bool chmax(T &, const T &);
template <class T>
bool chmin(T &, const T &);
ll gcd(ll, ll);
ll qp(ll a, ll b);
ll qp(ll a, ll b, ll mo);

ll mod_pow(ll, ll);
ll mod_add(ll, ll);
ll mod_mul(ll, ll);
ll mod_div(ll, ll);
void make_fact(ll);
void make_invfact(ll);
void init_fact();

ll combination(ll, ll);

#define FACSIZE 200002LL

ll invfac[FACSIZE];
ll fac[FACSIZE];

struct edge
{
  ll to, cost, id;
};

class Graph
{
public:
  ll N;
  vector<vector<edge>> G;
  vector<vector<edge>> Gin;
  vector<ll> his;

  Graph(ll N) : N(N)
  {
    G = vector<vector<edge>>(N, vector<edge>(0));
    Gin = vector<vector<edge>>(N, vector<edge>(0));
    his.resize(N);
  }

  void add_Directed_edge(ll from, ll to, ll cost = 1, ll id = 0)
  {
    G[from].push_back(edge({to, cost, id}));
    Gin[to].push_back(edge({from, cost, id}));
  }

  void add_Undirected_edge(ll v1, ll v2, ll cost = 1, ll id = 0)
  {
    add_Directed_edge(v1, v2, cost, id);
    add_Directed_edge(v2, v1, cost, id);
  }

  mat waeshall_floyd()
  {
    mat d(N, vec(N, INF));
    REP(i, N)
    d[i][i] = 0;
    REP(i, N)
    for (edge e : G[i])
    {
      d[i][e.to] = min(d[i][e.to], e.cost);
    }
    REP(k, N)
    REP(i, N)
    REP(j, N)
    d[i][j] = min(d[i][j], d[i][k] + d[k][j]);

    return d;
  }

  vec dikstra(ll x)
  {
    vec distance(N, INF);
    distance[x] = 0;
    PQG<pa> pque;
    pque.push(make_pair(0, x));

    while (!pque.empty())
    {

      auto pq = pque.top();
      pque.pop();
      for (auto e : G[pq.second])
      {
        ll d = distance[pq.second] + e.cost;
        if (d < distance[e.to])
        {
          distance[e.to] = d;
          pque.push(make_pair(d, e.to));
        }
      }
    }

    return distance;
  }

  bool dfs(ll x, vec &v, tTree &se)
  {
    //cout << x << endl;
    se.insert(x);
    v.PB(x);

    his[x] = 1;
    bool res = false;
    for (auto node : G[x])
    {
      if (se.find(node.to) != end(se))
      {
        v.PB(node.to);
        return true;
      }

      res |= dfs(node.to, v, se);
      if (res)
      {
        return true;
      }
    }
    v.pop_back();
    se.erase(x);
    return res;
  }
  bool dfs2(ll x, ll goal, vec &v, vec &dis)
  {
    //cout << "x:" << x << endl;
    v.PB(x);
    if (x == goal)
    {
      return true;
    }

    bool res = false;
    for (auto e : G[x])
    {
      //cout << "e:" << e.to << endl;

      if (dis[e.to] != dis[x] + 1)
        continue;

      res |= dfs2(e.to, goal, v, dis);
      if (res)
      {
        return true;
      }
    }
    v.pop_back();

    return res;
  }
};

int main(void)
{
  ll n, m;
  cin >> n >> m;
  Graph G(n);
  unordered_map<ll, ll> um[n];
  unordered_map<ll, ll> umIn[n];
  vec A(m);
  vec B(m);
  REP(i, m)
  {
    ll a, b;
    cin >> a >> b;
    A[i] = a - 1;
    B[i] = b - 1;
    G.add_Directed_edge(a - 1, b - 1, 1, i);
    um[a - 1][b - 1] = 1;
    umIn[b - 1][a - 1] = 1;
  }

  REP(i, n)
  {
    if (G.his[i] == 1)
      continue;
    tTree se;
    vec v;
    G.dfs(i, v, se);

    if (v.size() > 0)
    {

      ll s = *(end(v) - 1);
      ll e = *(end(v) - 2);
      vec loop;
      auto itr = begin(v);
      while (*itr != s)
        itr++;
      loop.PB(*itr);

      while (*itr != e)
      {
        itr++;
        loop.PB(*itr);
      }

      unordered_set<ll> unse;
      pa p = make_pair(s, e);
      for (auto x : loop)
        unse.insert(x);
      ll leng = loop.size() + 1;

      Graph Gnew(n);
      REP(i, m)
      {
        auto a = A[i];
        auto b = B[i];
        if (unse.find(a) != end(unse) && unse.find(b) != end(unse))
        {
          Gnew.add_Directed_edge(a, b);
        }
      }
      G = Gnew;

      for (ll i = 0; i < loop.size(); i++)
      {
        //auto dis = G.dikstra(loop[i]);

        for (ll j = i + 1; j < loop.size(); j++)
        {
          if (um[loop[j]].find(loop[i]) != end(um[loop[j]]))
          {
            if (leng > j - i)
            {
              leng = j - i;
              p = make_pair(loop[i], loop[j]);
            }
          }
        }
      }

      //cout << p.first << "," << p.second << endl;
      auto dis = G.dikstra(p.first);
      /*
      for (auto d : dis)
        cout << d << " ";
      cout << endl;
      //*/
      vec ans;
      G.dfs2(p.first, p.second, ans, dis);

      cout << ans.size() << endl;
      for (auto x : ans)
      {
        cout << x + 1 << endl;
      }

      return 0;
    }
  }
  cout << -1 << endl;

  return 0;
}

template <class T>
bool chmax(T &a, const T &b)
{
  if (a < b)
  {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
  if (b < a)
  {
    a = b;
    return 1;
  }
  return 0;
}

ll qp(ll a, ll b)
{
  ll ans = 1LL;
  do
  {
    if (b & 1LL)
      ans = 1LL * mod_mul(ans, a) % MOD;
    a = 1LL * mod_mul(a, a) % MOD;
  } while (b >>= 1LL);
  return ans;
}
ll qp(ll a, ll b, ll mo)
{
  ll ans = 1LL;
  do
  {
    if (b & 1LL)
      ans = 1LL * (ans % mo) * (a % mo);
    a = 1LL * (a % mo) * (a % mo);
  } while (b >>= 1LL);
  return ans;
}
ll gcd(ll a, ll b)
{
  return b ? gcd(b, a % b) : a;
}
ll mod_pow(ll x, ll r)
{
  if (r == 0)
    return 1;
  else if (r == 1)
    return x % MOD;
  else if (r % 2 == 0)
  {
    ll t = mod_pow(x, r / 2) % MOD;
    return t * t % MOD;
  }
  else
  {
    ll t = mod_pow(x, r / 2) % MOD;
    ll k = t * t % MOD;
    return k * x % MOD;
  }
}
ll mod_add(ll a, ll b)
{
  return (a + b) % MOD;
}

ll mod_mul(ll a, ll b)
{
  return (a * b) % MOD;
}

ll mod_div(ll a, ll b)
{
  return mod_mul(a, mod_pow(b, MOD - 2));
}

void make_fact(ll n)
{
  fac[0] = 1;
  REP(i, n)
  {
    fac[i + 1] = mod_mul(fac[i], i + 1);
  }
}

void make_invfact(ll n)
{
  invfac[n] = mod_pow(fac[n], MOD - 2);
  REP_R(i, n)
  {
    invfac[i] = mod_mul(invfac[i + 1], i + 1);
  }
}

void init_fact()
{
  make_fact(FACSIZE - 1);
  make_invfact(FACSIZE - 1);
}

ll combination(ll n, ll c)
{

  return mod_mul(fac[n], mod_mul(invfac[c], invfac[n - c]));
}
///////////////fact
/*
  init_fact();
  cout << fac[5] << endl;
  cout << invfac[5] << endl;
  cout << combination(8, 4) << endl;
  cout << combination(31, 8) << endl;
  //*/
///////////////////

Measured memory_bytes: 1024