#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<int> v[100009];
int h[100009];
int dp[100009];
int edges[100009][2];
map<pair<int, int>, int> mapp;
int DFS(int st) {
  if (dp[st] != -1) return dp[st];
  int i, j, ans = 0, mm = 0;
  for (i = 0; i < v[st].size(); i++) {
    int a = DFS(v[st][i]);
    if (a > ans) {
      ans = a;
      mm = v[st][i];
    }
  }
  if (mm != 0) mapp[make_pair(st, mm)] = 1;
  return dp[st] = ans + 1;
}
int main() {
  scanf("%d%d", &n, &m);
  int i, j, a, b;
  for (i = 0; i < m; i++) {
    scanf("%d%d", &a, &b);
    v[a].push_back(b);
    h[b] = 1;
    edges[i][0] = a;
    edges[i][1] = b;
  }
  int c = 0;
  for (i = 1; i <= n; i++) {
    if (h[i] == 0) c++;
    dp[i] = -1;
  }
  if (c == 1) {
    for (i = 1; i <= n; i++) {
      if (h[i] == 0) break;
    }
    int ans = DFS(i);
    if (ans != n) {
      printf("-1\n");
    } else {
      for (i = m - 1; i >= 0; i--) {
        a = edges[i][0];
        b = edges[i][1];
        if (mapp.find(make_pair(a, b)) != mapp.end()) break;
      }
      printf("%d\n", i + 1);
    }
  } else {
    printf("-1\n");
  }
  return 0;
}
