#include <stdio.h>
#include <algorithm>
#include <queue>
#include <limits.h>
#include <string.h>
const int N = 2e3+10;
int q[N], cnt=INT_MAX;
struct edge {
	int next, to;
}e[N*2];
int head[N], sum;
inline void add(int x, int y) {
	e[++sum].next = head[x];
	head[x] = sum;
	e[sum].to = y;
}
int h[N];
bool vis[N];
int fa[N];
inline void BFS(int S) {
	std::queue<int> q;
	h[S] = 1;
	fa[S] = 0;
	q.push(S);
	memset(vis, 0, sizeof(vis));
	vis[S] = 1;
	while (!q.empty()) {
		int now = q.front();
//		printf("%d\n", now);
		q.pop();
		for (int i=head[now]; i; i=e[i].next) {
			int to = e[i].to;
			if (to == S) {
				if (h[now]-h[S]+1 < cnt) {
					cnt = 0;
					for (int i=now; i; i=fa[i]) {
						::q[++cnt] = i;
					}
				}
				continue;
			}
			if (!vis[to]) {
				fa[to] = now;
				h[to] = h[now]+1;
				vis[to] = 1;
				q.push(to);
			}
		}
	}
}
int n, m;
int main() {
	scanf("%d%d", &n, &m);
	for (int i=1; i<=m; i++) {
		int x, y;
		scanf("%d%d", &x, &y);
		add(x, y);
	}
	for (int i=1; i<=n; i++) {
		BFS(i);
	}
	if (cnt == INT_MAX) {
		printf("-1\n");
		return 0;
	}
	printf("%d\n", cnt);
	for (int i=1; i<=cnt; i++) {
		printf("%d\n", q[i]);
	}
	return 0;
}