/**
 * Created by hiroqn on 13/10/05.
 */

var fs = require('fs'),
    length = fs.fstatSync(process.stdin.fd).size,
    buffer = new Buffer(length),
    bytesRead = fs.readSync(process.stdin.fd, buffer, 0, length, 0),
    input = buffer.toString('utf8', 0, bytesRead).split('\n');


function pickGraph(g, edge) {
  var a = edge[0],
      b = edge[1],
      g2 = g.slice();
  (g2[a] = g[a].slice()).splice(g[a].indexOf(b), 1);
  return g2;
}

function countRoom(g) {
  var d = [], i, j, max = 1;
  for (i = 0; i < n; i++) {
    d[i] = 1;
  }
  for (i = 0; i < n; i++) {
//    d[i]++;
    for (j = 0; j < g[i].length; j++) {
      d[g[i][j]] = Math.max(d[g[i][j]], d[i] + 1);
    }
//    max = Math.max(max, d[i]);
  }
  return Math.max.apply(null, d);
}
function getNRoom(graph, nodeList){
  var d = [], i, j, node;
  for (i = 0; i < nodeList.length; i++) {
    d[nodeList[i]] = 1;
  }
  for (i = 0; i < nodeList.length; i++) {
    node = nodeList[i];
//    d[i]++;
    for (j = 0; j < g[i].length; j++) {
      d[g[i][j]] = Math.max(d[g[i][j]], d[i] + 1);
    }
//    max = Math.max(max, d[i]);
  }
  return Math.max.apply(null, d);
}
function union(x, y) {
  x = find(x);
  y = find(y);
  if (x !== y) {
    if (par[x] < par[y]) {
      par[x] += par[y];
      par[y] = x;
    } else {
      par[y] += par[x];
      par[x] = y;
    }
  }
  return x !== y;
}
function find(x) {
  return par[x] < 0 ? x : par[x] = find(par[x]);
}


var temp = input.shift().split(' '),
    n = temp[0],
    m = temp[1],
    edges = [],
    graph,
    graph2,
    i, a, b;
//make graph and unnion find
var g = [],
    nodesListGroup = [],
    par = [];
for (i = 0; i < n; i++) {
  par[i] = -1;
  nodesListGroup[i] = [];
  g[i] = [];
}

for (i = 0; i < m; i++) {
  temp = input[i].split(' ');
  a = temp[0] - 1;
  b = temp[1] - 1;
  edges[i] = [a, b];//edges
  g[a].push(b); // make graph
//  union(a, b);// union find
}
//
//for (i = 0; i < n; i++) {
//  nodesListGroup[find(i)].push(i);
//}
//nodesListGroup = nodesListGroup.filter(function (e, i) {
//  return e.length > 0;
//});
//var nrgroup = nodesListGroup.map(function(nodeList){//number room group
//
//})
//for (i = 0; i < nodesListGroup.length; i++) {
//
//}
var nRooms = countRoom(g),
    flag = false;
for (i = 0; i < m; i++) {
  graph2 = pickGraph(g, edges[i]);
  if (countRoom(graph2) < nRooms) {
    console.log(i + 1);
    flag = true
  }
}
if (!flag) {
  console.log(-1);
}