#include "bits/stdc++.h"
#include<random>
using namespace std;
typedef long long int lint;
typedef pair<lint, lint> plint;
typedef pair<double long, double long> pld;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(lint i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
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; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first - r.first, l.second - r.second); }
const lint MOD = 998244353, INF = 1e16;


template <std::int_fast64_t Modulus>
class modint
{
	using u64 = std::int_fast64_t;

public:
	u64 a;
	constexpr modint(const u64 x = 0) noexcept : a(x% Modulus) {}
	constexpr u64& value() noexcept { return a; }
	constexpr const u64& value() const noexcept { return a; }
	constexpr modint operator+(const modint rhs) const noexcept
	{
		return modint(*this) += rhs;
	}
	constexpr modint operator-(const modint rhs) const noexcept
	{
		return modint(*this) -= rhs;
	}
	constexpr modint operator*(const modint rhs) const noexcept
	{
		return modint(*this) *= rhs;
	}
	constexpr modint operator/(const modint rhs) const noexcept
	{
		return modint(*this) /= rhs;
	}
	constexpr modint& operator+=(const modint rhs) noexcept
	{
		a += rhs.a;
		if (a >= Modulus)
		{
			a -= Modulus;
		}
		return *this;
	}
	constexpr modint& operator-=(const modint rhs) noexcept
	{
		if (a < rhs.a)
		{
			a += Modulus;
		}
		a -= rhs.a;
		return *this;
	}
	constexpr modint& operator*=(const modint rhs) noexcept
	{
		a = a * rhs.a % Modulus;
		return *this;
	}
	constexpr modint& operator/=(modint rhs) noexcept
	{
		u64 exp = Modulus - 2;
		while (exp)
		{
			if (exp % 2)
			{
				*this *= rhs;
			}
			rhs *= rhs;
			exp /= 2;
		}
		return *this;
	}
};
typedef modint<MOD> ModInt;

lint N, M, A, B;
vector<lint> to[1000];
set<lint> st;
int main() {
	cin >> N >> M;
	REP(i, M) {
		cin >> A >> B; A--; B--;
		to[A].push_back(B);
	}

	REP(i, N) {
		lint from[1000];
		lint dp[1000];
		REP(i, N) {
			from[i] = INF;
			dp[i] = INF;
		}
		queue<lint> que;
		que.push(i);
		dp[i] = 0;
		bool flag = false;
		lint cost = 0;
		while (!que.empty()) {
			lint curr = que.front(); que.pop();
			REP(j, SZ(to[curr])) {
				lint next = to[curr][j];
				if (dp[next] > dp[curr] + 1) {
					dp[next] = dp[curr] + 1;
					from[next] = curr;
					que.push(next);
				}
				if (next == i) {
					flag = true;
					cost = dp[curr] + 1;
					from[i] = curr;
				}
			}
			if (flag) break;
		}
		lint bak = from[i], prv = i;
		if (bak == INF) continue;
		set<lint> st;
		st.insert(i);
		bool fl = false;
		while (bak != i) {
			st.insert(bak);
			bak = from[bak];
		}

		lint cnt = 0;
		REP(j, SZ(to[from[i]])) {
			if (st.find(to[from[i]][j]) != st.end()) cnt++;
		}
		if (cnt > 1) continue;

		bak = from[i];
		while (bak != i) {
			prv = bak;
			bak = from[bak];
			REP(j, SZ(to[bak])) {
				if (to[bak][j] != prv && st.find(to[bak][j]) != st.end()) fl = true;
			}
		}
		if (!fl) {
			cout << SZ(st) << endl;
			for (auto itr : st) {
				cout << itr + 1 << endl;
			}
			return 0;
		}
	}
	cout << "-1" << endl;
}


Measured memory_bytes: 3756