#include <bits/stdc++.h>
using namespace std;
int n, m, in[100007], st[100007];
vector<pair<int, int> > v[100007];
pair<int, int> t[100007];
pair<int, int> dfs(int u, int deep) {
  int i, j;
  pair<int, int> ans = make_pair(-1, 0), w;
  st[u] = 1;
  ans.first = 0;
  for (i = 0; i < v[u].size(); i++) {
    if (st[v[u][i].first] == 0) {
      w = dfs(v[u][i].first, deep + 1);
      w.second = max(w.second, v[u][i].second);
    } else {
      w = t[v[u][i].first];
      w.second = max(w.second, v[u][i].second);
    }
    if (ans.first < w.first + 1) {
      ans.first = max(ans.first, w.first + 1);
      ans.second = w.second;
    } else {
      if (ans.first == w.first + 1) {
        ans.second = min(ans.second, w.second);
      }
    }
  }
  t[u] = ans;
  return ans;
}
void solve() {
  int i, j;
  for (i = 0; i < 100007; i++) {
    in[i] = 0;
    st[i] = 0;
  }
  int x, y;
  scanf("%d%d", &n, &m);
  for (i = 0; i < m; i++) {
    scanf("%d%d", &x, &y);
    x -= 1;
    y -= 1;
    in[y]++;
    v[x].push_back(make_pair(y, i + 1));
  }
  int ans = 1e9;
  pair<int, int> q;
  for (i = 0; i < n; i++) {
    if (in[i] == 0) {
      q = dfs(i, 1);
      if (q.first == n - 1) ans = min(ans, q.second);
    }
  }
  if (ans == 1e9) ans = -1;
  printf("%d", ans);
}
int main() {
#pragma comment(linker, "/STACK:268435456"
  solve();
  return 0;
}
