#include <bits/stdc++.h>
using namespace std;
int dr[] = {1, 0, -1, 0, -1, -1, 1, 1};
int dc[] = {0, -1, 0, 1, -1, 1, -1, 1};
const int MAX = 1e6 + 7;
const int MOD = 1e9 + 7;
vector<vector<pair<long long, long long>>> G;
pair<long long, long long> mem[MAX];
pair<long long, long long> mx(pair<long long, long long> a,
                              pair<long long, long long> b) {
  if (a.first == b.first)
    return pair<long long, long long>(a.first, min(a.second, b.second));
  if (a.first < b.first) return b;
  return a;
}
pair<long long, long long> DFS(int node) {
  if (mem[node].first != -1) return mem[node];
  pair<long long, long long> ret(0, 0);
  for (long long i = 0; i < (long long)G[node].size(); ++i) {
    pair<long long, long long> child = G[node][i];
    pair<long long, long long> r = DFS(child.first);
    r.second = max(child.second, r.second);
    ret = mx(r, ret);
  }
  return mem[node] = pair<long long, long long>(ret.first + 1, ret.second);
}
int main() {
  int n, m;
  cin >> n >> m;
  G.resize(n);
  for (long long i = 0; i < n; ++i) mem[i].first = -1;
  for (long long i = 0; i < m; ++i) {
    int x, y;
    cin >> x >> y;
    G[--x].push_back(pair<long long, long long>(--y, i));
  }
  long long ans = 1e18;
  for (long long i = 0; i < n; ++i) {
    pair<long long, long long> r = DFS(i);
    if (r.first == n) ans = min(r.second, ans);
  }
  if (ans == 1e18)
    cout << "-1\n";
  else
    cout << ans + 1 << "\n";
}
