#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
void *wmem;
char memarr[96000000];
template<class T> inline void walloc1d(T **arr, int x, void **mem = &wmem){
  static int skip[16] = {0, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1};
  (*mem) = (void*)( ((char*)(*mem)) + skip[((unsigned long long)(*mem)) & 15] );
  (*arr)=(T*)(*mem);
  (*mem)=((*arr)+x);
}
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  int s=0;
  int m=0;
  char f[10];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
struct graph{
  int N;
  int *es;
  int **edge;
  void setDirectEdge(int N__, int M, int A[], int B[], void **mem = &wmem){
    int i;
    N = N__;
    walloc1d(&es, N, mem);
    walloc1d(&edge, N, mem);
    walloc1d(&edge[0], M, mem);
    for(i=(0);i<(N);i++){
      es[i] = 0;
    }
    for(i=(0);i<(M);i++){
      es[A[i]]++;
    }
    for(i=(0);i<(N);i++){
      walloc1d(&edge[i], es[i], mem);
    }
    for(i=(0);i<(N);i++){
      es[i] = 0;
    }
    for(i=(0);i<(M);i++){
      edge[A[i]][es[A[i]]++] = B[i];
    }
  }
  int shortestPath(const int s, const int t, int res[], void *mem=wmem){
    int i;
    int j;
    int k;
    int *q;
    int qs = 0;
    int qe = 0;
    int *b;
    walloc1d(&b, N, &mem);
    walloc1d(&q, N, &mem);
    for(i=(0);i<(N);i++){
      b[i] = -1;
    }
    b[s] = -2;
    q[qe++] = s;
    while(qe > qs){
      i = q[qs++];
      for(j=(0);j<(es[i]);j++){
        k = edge[i][j];
        if(b[k]!=-1){
          continue;
        }
        b[k] = i;
        q[qe++] = k;
      }
      if(b[t]!=-1){
        break;
      }
    }
    if(b[t]==-1){
      return -1;
    }
    k = 0;
    res[k] = i = t;
    while(i != s){
      res[++k] = (i = b[i]);
    }
    std::reverse(res, res+k+1);
    return k;
  }
}
;
int N;
int M;
int A[2000];
int B[2000];
int x[2000];
int y[2000];
int m;
int pth[2000];
int ress;
int res[2000];
int main(){
  int k;
  wmem = memarr;
  int d;
  void *mem;
  graph g;
  rd(N);
  rd(M);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=(0);Lj4PdHRW<(M);Lj4PdHRW++){
      rd(A[Lj4PdHRW]);A[Lj4PdHRW] += (-1);
      rd(B[Lj4PdHRW]);B[Lj4PdHRW] += (-1);
    }
  }
  ress = 1073709056;
  for(k=(0);k<(M);k++){
    int i;
    mem = wmem;
    m = 0;
    for(i=(0);i<(M);i++){
      if(i!=k){
        x[m] = A[i];
        y[m++] = B[i];
      }
    }
    g.setDirectEdge(N, m, x, y);
    d = g.shortestPath(B[k], A[k], pth);
    if(d >= 0){
      d++;
      if(ress > d){
        sort(pth, pth + d);
        ress = d;
        for(i=(0);i<(d);i++){
          res[i] = pth[i] + 1;
        }
      }
    }
    wmem = mem;
  }
  if(ress == 1073709056){
    wt_L(-1);
    wt_L('\n');
    return 0;
  }
  wt_L(ress);
  wt_L('\n');
  {
    int KL2GvlyY;
    for(KL2GvlyY=(0);KL2GvlyY<(ress);KL2GvlyY++){
      wt_L(res[KL2GvlyY]);
      wt_L('\n');
    }
  }
  return 0;
}
// cLay varsion 20190928-1

// --- original code ---
// int N, M, A[2000], B[2000];
// int x[2000], y[2000], m, pth[2000];
// int ress, res[2000];
// {
//   int d;
//   void *mem;
//   graph g;
// 
//   rd(N,M,(A--,B--)(M));
// 
//   ress = int_inf;
//   rep(k,M){
//     mem = wmem;
//     m = 0;
//     rep(i,M) if(i!=k) x[m] = A[i], y[m++] = B[i];
//     g.setDirectEdge(N, m, x, y);
//     d = g.shortestPath(B[k], A[k], pth);
//     if(d >= 0){
//       d++;
//       if(ress > d){
//         sort(pth, pth + d);
//         ress = d;
//         rep(i,d) res[i] = pth[i] + 1;
//       }
//     }
//     wmem = mem;
//   }
//   if(ress == int_inf) wt(-1), return 0;
//   wtLn(ress, res(ress));
// }


Measured memory_bytes: 384