//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <iomanip>
#include <iostream>
#include <limits>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = int64_t;
using ull = uint64_t;

template<typename T>
vector<T> make_vec_nd(T init, size_t size) {
    return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, size_t size, Args... rest) {
    auto inner = make_vec_nd(init, rest...);
    return vector<decltype(inner)>(size, inner);
}

void visit(ll v, const vector<vector<ll>>& graph, vector<uint8_t>& is_visit, vector<ll>& out_loop) {
    if (is_visit[v] == 1) {
        out_loop.push_back(v);
        return;
    }
    if (is_visit[v] == 2) {
        return;
    }
    is_visit[v] = 1;
    for (ll to : graph[v]) {
        visit(to, graph, is_visit, out_loop);
        if (out_loop.size() > 0) {
            if (!(out_loop.size() >= 2 && out_loop.front() == out_loop.back())) {
                out_loop.push_back(v);
            }
            return;
        }
    }
    is_visit[v] = 2;
}

int main() {
    ll N, M;
    cin >> N >> M;
    vector<vector<ll>> graph(N);
    for (ll i = 0; i < M; i++) {
        ll from;
        ll to;
        cin >> from >> to;
        from--;
        to--;
        graph[from].push_back(to);
    }
    vector<ll> out_loop;
    vector<uint8_t> is_visit(N);
    for (ll i = 0; i < N; i++) {
        if (is_visit[N] == 2) {
            continue;
        }
        visit(i, graph, is_visit, out_loop);
        if (out_loop.size() > 0) {
            break;
        }
    }
    if (out_loop.size() == 0) {
        cout << -1 << endl;
        return 0;
    }
    assert(out_loop.size() >= 2);
    out_loop.pop_back();
    reverse(out_loop.begin(), out_loop.end());
    vector<ll> ans;
    for (ll start = 0; start < out_loop.size(); start++) {
        unordered_map<ll, ll> out_loop_order;
        for (ll i = 0; i < out_loop.size(); i++) {
            ll ord;
            if (i == 0) {
                ord = out_loop.size();
            } else {
                ord = i;
            }
            out_loop_order[out_loop[(start + i) % out_loop.size()]] = ord;
        }
        vector<ll> ans_local;
        ll now = out_loop[start];
        ans_local.push_back(now);
        while (true) {
            ll max_vertex = -1;
            ll max_vertex_order = numeric_limits<ll>::min();
            for (ll to : graph[now]) {
                auto it = out_loop_order.find(to);
                if (it != out_loop_order.end() && it->second > max_vertex_order) {
                    max_vertex_order = it->second;
                    max_vertex = to;
                }
            }
            if (max_vertex == out_loop[start]) {
                break;
            }
            ans_local.push_back(max_vertex);
            now = max_vertex;
        }
        if (ans.size() == 0 || ans.size() > ans_local.size()) {
            ans = move(ans_local);
        }
    }
    cout << ans.size() << endl;
    for (ll i = 0; i < ans.size(); i++) {
        cout << ans[i] + 1 << endl;
    }
    return 0;
}




Measured memory_bytes: 512