// #define DEBUGGING
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()

template <typename T> using V = vector<T>;
template <typename T> using VV = V<V<T>>;
using ll = int64_t;
using ull = uint64_t;
using PLL = pair<ll, ll>;

template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return max(low, min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { t = clamp(t, low, high); }

namespace init__ {

struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

}

#ifdef DEBUGGING
// #include "../debug/debug.cpp"
#include "../../debug/debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif

template <typename T>
T make_v(T init) { return init; }

template <typename T, typename... Tail>
auto make_v(T init, size_t s, Tail... tail) {
#define rec make_v(init, tail...)
    return V<decltype(rec)>(s, rec);
#undef rec
}

VV<ll> edges;
V<bool> used;
V<bool> visited;

bool check(stack<ll> &st, ll front) {
    DEBUG(front, st.size());
    set<ll> n_set = { front };
    stack<ll> serve;
    while(st.size()) {
        ll t = st.top();
        st.pop();
        serve.push(t);
        n_set.insert(t);
        if(t == front) break;
    }
    while(serve.size()) {
        st.push(serve.top());
        serve.pop();
    }
    for(ll n : n_set) {
        ll cnt = 0;
        for(ll nxt : edges[n]) if(n_set.find(nxt) != n_set.end()) cnt++;
        if(cnt != 1) return false;
    }
    return true;
}

pair<ll, stack<ll>> dfs(ll cur, stack<ll> &stk) {
    DEBUG(cur);
    stk.push(cur);
    used[cur] = true;
    visited[cur] = true;
    for(ll nxt : edges[cur]) {
        if(used[nxt]) {
            if(check(stk, nxt)) return make_pair(nxt, stk);
            else continue;
        }
        auto res = dfs(nxt, stk);
        if(res.first != -1) return res;
    }
    used[cur] = false;
    stk.pop();
    return make_pair(-1, stack<ll>());
}

V<ll> ans;

ll solve() {
    ll N, M;
    cin >> N >> M;
    edges.resize(N);
    used.resize(N);
    visited.resize(N);
    while(M--) {
        ll a, b;
        cin >> a >> b;
        a--; b--;
        edges[a].push_back(b);
    }
    for(ll i = 0; i < N; i++) {
        if(visited[i]) continue;
        ll num;
        stack<ll> stk, stk_res;
        tie(num, stk_res) = dfs(i, stk);
        if(num == -1) continue;
        while(stk_res.size()) {
            ll tp = stk_res.top();
            ans.push_back(tp);
            stk_res.pop();
            if(tp == num) break;
        }
        return ans.size();
    }
    return -1;
}

int main() {
    ll ret = solve();
    cout << ret << endl;
    DEBUG(ans);
    if(ret != -1) for(auto &&ele : ans) cout << ele + 1 << endl;
    return 0;
}


Measured memory_bytes: 768