import std.stdio;
import std.conv;
import std.array;
import std.algorithm;

class Node {
    int index;
    Node parent;
    Node[] children;
    this(int index) {
        this.index = index;
    }
    private int _rank = 0;
    @property int rank() {
        if (_rank > 0) return _rank;
        foreach (child; children) {
            _rank = max(_rank, child.rank);
        }
        _rank++;
        return _rank;
    }

    private int _count = 0;
    @property int count() {
        if (_count > 0) return _count;
        foreach (child; children) {
            if (child.rank + 1 == rank) {
                _count++;
            }
        }
        return _count;
    }

    bool check(Node child) {
        return count == 1 && rank == child.rank + 1;
    }
}

void main() {
    int n, m; readf("%d %d\n", &n, &m);
    Node[] employees = new Node[n + 1];
    foreach (i; 1 .. n + 1) {
        employees[i] = new Node(i);
    }
    int[] as = new int[m];
    int[] bs = new int[m];
    foreach (i; 0 .. m) {
        int a, b; readf("%d %d\n", &a, &b);
        as[i] = a; bs[i]  = b;
        employees[a].children ~= employees[b];
        employees[b].parent = employees[a];
    }

    int[] ans;
    foreach (i; 0 .. m) {
        int a = as[i];
        int b = bs[i];
        if (employees[a].check(employees[b])) {
            ans ~= i + 1;
        }
    }

    (ans.length ? ans.map!(to!string).join("\n") : "-1").writeln;

    /*foreach (i; 1 .. n + 1) {
        writeln("Emp ", i, ",rank: ", employees[i].rank,
                ",count: ", employees[i].count);
    }*/
}