// 去吧！皮卡丘! 把AC带回来！
//      へ　　　　　／|
// 　　/＼7　　　 ∠＿/
// 　 /　│　　 ／　／								AC		AC		AC		AC
//    │　Z ＿,＜　／　　 /`ヽ						AC		AC		AC		AC
//    │　　　　　ヽ　　 /　　〉					AC		AC		AC		AC
// 　Y　　　　　`　 /　　/  /						AC		AC		AC		AC
// 　亻●　.　●　　〈　/　/						AC		AC		AC		AC
// 　()　 へ　　　　|　＼〈							AC		AC		AC		AC
// 　　>- ._　 ィ　 │ ／／							AC		AC		AC		AC
// 　 / へ　　 /　/＜| ＼＼							AC		AC		AC		AC
// 　 ヽ_/　　(_／　 │／／							AC		AC		AC		AC
// 　　 7　　　　　　　|／							AC		AC		AC		AC
// 　　 ＞―r￣￣`-―＿/							AC		AC		AC		AC
//**************************************Accepted*****************************************//

#include<bits/stdc++.h>

#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define Unique(x) x.erase(unique(all(x)),x.end());

#define CIN_FILE "input.txt"
#define COUT_FILE "output.txt"

#define Pig (OO)

using namespace std;

const int dx[]={-1,0,1,0};
const int dy[]={0,-1,0,1};

const int Days[]={-1,31,28,31,30,31,30,31,31,30,31,30,31};

inline int read()
{
	#define gc getchar
	int ans=0;
	bool f=1;
	char ch=gc();
	
	while(!isdigit(ch))f^=ch=='-',ch=gc();
	
	while(isdigit(ch))ans=((ans<<2)+ans<<1)+(ch^48),ch=gc();
	
	return f?ans:-ans;
	
	#undef gc
}

typedef long long ll;

int n,m;
vector<int> v[1010];
int vis[1010];
vector<int> path;
int indeg[1010],outdeg[1010];
bool edges[1010][1010];

bool OK()
{
	memset(indeg,0,sizeof(indeg));
	memset(outdeg,0,sizeof(outdeg));
	
	for(int i=0;i<path.size();i++)for(int j=0;j<path.size();j++)
	{
		if(indeg[path[i]]>1||outdeg[path[j]]>1)return 0;
		
		if(edges[path[i]][path[j]])indeg[path[i]]++,outdeg[path[j]]++;
	}
	
	for(int i=0;i<path.size();i++)if(indeg[path[i]]!=1||outdeg[path[i]]!=1)return 0;
	
	return 1;
}

void pprint()
{
	if(!OK())return;
	
	cout<<path.size()<<endl;for(int i=0;i<path.size();i++)cout<<path[i]<<endl;
	
	exit(0);
}

void DFS(int x)
{
	path.pb(x);
	vis[x]=2;
	
	for(int i=0;i<v[x].size();i++)
	{
		if(vis[v[x][i]]==0)DFS(v[x][i]);
		if(vis[v[x][i]]==2)pprint();
	}
	
	path.pop_back();
	vis[x]=1;
}

int main(int argc, char const *argv[])
{
	ios::sync_with_stdio(false);
	
	cin>>n>>m;
	
	for(int i=0;i<m;i++)
	{
		int x,y;
		cin>>x>>y;
		
		v[x].pb(y);
		
		edges[x][y]=1;
	}
	
	for(int i=1;i<=n;i++)
	{
		memset(vis,0,sizeof(vis));
		path.clear();
		
		if(!vis[i])DFS(i);
	}
	
	cout<<-1;
	
	//printf("Time used = %.12f",(double)(clock())/CLOCKS_PER_SEC);
	return 0;
}

/*  GOD BLESS  */

#include <bits/stdc++.h>

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

using namespace std;

std::vector<std::vector<int>> StronglyConnectedComponents(
    const std::vector<std::vector<int>>& graph) {
  int n = graph.size();
  std::vector<int> nodes;
  std::vector<bool> visited(n);
  std::function<void(int)> dfs = [&](int u) {
    visited[u] = true;
    for (int v : graph[u]) {
      if (!visited[v]) {
        dfs(v);
      }
    }
    nodes.push_back(u);
  };
  for (int u = 0; u < n; ++u) {
    if (!visited[u]) dfs(u);
  }
  std::vector<std::vector<int>> rgraph(n);
  for (int u = 0; u < n; ++u) {
    for (int v : graph[u]) {
      rgraph[v].push_back(u);
    }
  }
  std::vector<bool> rvisited(n);
  std::vector<std::vector<int>> sccs;
  std::function<void(std::vector<int>&, int)> rdfs = [&](std::vector<int>& scc,
                                                         int u) {
    rvisited[u] = true;
    scc.push_back(u);
    for (int v : rgraph[u]) {
      if (!rvisited[v]) {
        rdfs(scc, v);
      }
    }
  };
  for (int i = n - 1; i >= 0; --i) {
    int u = nodes[i];
    if (!rvisited[u]) {
      std::vector<int> scc;
      rdfs(scc, u);
      sccs.push_back(scc);
    }
  }
  return sccs;
}

int main() {
  in(int, n, m);
  vector<vector<int>> graph(n);
  rep(i, m) {
    in(int, a, b);
    graph[a - 1].push_back(b - 1);
  }
  vector<vector<int>> sccs = StronglyConnectedComponents(graph);
  for (const vector<int>& scc : sccs) {
    if (scc.size() == 1) continue;
    set<int> scc_nodes(all(scc));
    int node = scc[0];
    map<int, int> next;
    map<int, int> prev;
    for (int n : scc_nodes) dbg(n);
    while (true) {
      for (int child : graph[node]) {
        if (scc_nodes.count(child) == 0) continue;
        next[node] = child;
        prev[child] = node;
        if (next.count(child) != 0) goto out;
        node = child;
        break;
      }
    }
 out:
    node = scc[0];
    if (prev.count(node) == 0) {
      while (true) {
        int child = next[node];
        next.erase(node);
        if (prev[child] != node) break;
        prev.erase(child);
        node = child;
      }
    }
    rep(u, n) for (int v : graph[u]) {
      if (next.count(u) > 0 && next.count(v) > 0) {
        int c = next[u];
        while (c != v) {
          int nc = next[c];
          next.erase(c);
          prev.erase(c);
          c = nc;
        }
        next[u] = v;
        prev[v] = u;
      }
    }
    vector<int> v;
    int u = next.begin()->first;
    do {
      v.push_back(u);
      u = next[u];
    } while (u != next.begin()->first);
    out(v.size());
    for (int u : v) out(u + 1);
    return 0;
  }
  out(-1);
}
