#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int>> g[100001];
pair<int, int> dp[100001];
int gmaxi = 0, n, m, gmaxipos;
void dfs(int beta) {
  if (dp[beta].first != -1) return;
  int maxi = 1, maxpos = 0;
  for (int i = 0; i < g[beta].size(); i++) {
    pair<int, int> pota = g[beta][i];
    dfs(pota.first);
    if (maxi < 1 + dp[pota.first].first) {
      maxpos = max(pota.second, dp[pota.first].second);
      maxi = 1 + dp[pota.first].first;
    }
  }
  dp[beta].first = maxi;
  dp[beta].second = maxpos;
  if (gmaxi < dp[beta].first) {
    gmaxi = dp[beta].first;
    gmaxipos = dp[beta].second;
  }
}
void init() {
  for (int i = 1; i <= n; i++) {
    dp[i].first = -1;
    dp[i].second = 0;
  }
}
int main() {
  scanf("%d", &n);
  scanf("%d", &m);
  for (int i = 0; i < m; i++) {
    int x, y;
    scanf("%d", &x);
    scanf("%d", &y);
    g[x].push_back(make_pair(y, i + 1));
  }
  init();
  for (int i = 1; i <= n; i++) {
    if (dp[i].first == -1) {
      dfs(i);
    }
  }
  if (gmaxi < n)
    printf("-1\n");
  else
    printf("%d\n", gmaxipos);
  return 0;
}
