#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
const int inf = INT_MAX;
const int lim = 1e5 + 5;
int power(int a, int b) {
  int ret = 1;
  while (b) {
    if (b & 1) ret *= a;
    a *= a;
    if (ret >= mod) ret %= mod;
    if (a >= mod) a %= mod;
    b >>= 1;
  }
  return ret;
}
int inv(int x) { return power(x, mod - 2); }
int n, m, a[lim], b[lim];
bool go(int idx) {
  vector<int> v[lim];
  int in[lim];
  memset(in, 0, sizeof(in));
  for (int i = 0; i < idx; i++) {
    in[b[i]]++;
    v[a[i]].push_back(b[i]);
  }
  queue<int> q;
  for (int i = 0; i < n; i++)
    if (!in[i + 1]) q.push(i + 1);
  if ((int)q.size() != 1) return false;
  int ans = 0;
  while (!q.empty()) {
    int p = q.front();
    q.pop();
    in[p]--;
    ans++;
    for (auto it : v[p]) {
      in[it]--;
      if (!in[it]) q.push(it);
    }
    if ((int)q.size() > 1) return false;
  }
  return (ans == n);
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < m; i++) scanf("%d%d", &a[i], &b[i]);
  int low = 1, high = m + 1;
  while (low < high) {
    int mid = (low + high) >> 1;
    if (go(mid))
      high = mid;
    else
      low = mid + 1;
  }
  if (high == m + 1)
    cout << -1 << endl;
  else
    cout << high << endl;
}
