#include <bits/stdc++.h>
#pragma comment(linker, "/stack:20000000")
using namespace std;
void redirectIO() {}
int n;
pair<int, int> inputs[100001];
pair<int, int> edges[100001];
int listStart[100001];
int pathLen[100001];
int getLen(int node) {
  if (edges[listStart[node]].first != node) return 0;
  if (pathLen[node]) return pathLen[node];
  int best = 0;
  for (int edge = listStart[node]; edges[edge].first == node; edge++) {
    int r = getLen(edges[edge].second) + 1;
    if (r > best) best = r;
  }
  return pathLen[node] = best;
}
bool check(int m) {
  memcpy(edges, inputs, m * sizeof(pair<int, int>));
  sort(edges, edges + m);
  edges[m] = make_pair((10000000), (0));
  listStart[1] = 0;
  int nowAt = 0;
  for (int i = 1; i <= n; i++) {
    while (edges[nowAt].first < i) nowAt++;
    listStart[i] = nowAt;
  }
  memset(pathLen, 0, (n + 1) * sizeof(int));
  for (int i = 1; i <= n; i++) {
    if (getLen(i) == n - 1) return true;
  }
  return false;
}
int main() {
  redirectIO();
  int m;
  while (cin >> n >> m) {
    for (int i = 0; i < (m); ++i) cin >> inputs[i].first >> inputs[i].second;
    int mmin = 0;
    int mmax = m;
    while (mmin < mmax) {
      int mid = (mmin + mmax) / 2;
      if (check(mid))
        mmax = mid;
      else
        mmin = mid + 1;
    }
    if (mmin == m && !check(m))
      cout << -1 << endl;
    else
      cout << mmin << endl;
  }
  return 0;
}
