Company trip

Problem Statement

Your company has n employees. For a group of m employees (a_i, b_i), a_i is the boss of b_i.

When employee x is the actual boss of employee y, it means that at least one of the following holds.


* x is y's boss.
* There is an employee z who is the actual boss of y, and x is the boss of z.



There are no employees in your company who are their actual bosses.

Your company is planning an employee trip with all employees participating. At the request of all employees, the room allocation at the inn must be "good room allocation".
A "good room allocation" means that both of the following are satisfied.


* Each employee is assigned to some room.
* When employee x and employee y are assigned to the same room, x is not the actual boss of y.



Since the secretary's employees are very talented, we allocated the rooms so that they were "good room allocation" and the number of required rooms was minimized. But unfortunately the budget is insufficient. It seems that the number of rooms required must be reduced.
Therefore, you who work in the human resources department decided to reduce the number of rooms required to obtain a "good room allocation" by eliminating only one boss-subordinate relationship.
Now, which relationship should be resolved?

Constraints

* 2 ≤ n ≤ 10 ^ 5
* 1 ≤ m ≤ 2 \ times 10 ^ 5
* 1 ≤ a_i <b_i ≤ n
* If i \ neq j, then (a_i, b_i) \ neq (a_j, b_j)

Input

Input follows the following format. All given numbers are integers.


n m
a_1 b_1
...
a_m b_m

Output

Output i that satisfies the following in ascending order, line by line.

* When the relationship "a_i is the boss of b_i" is resolved, the number of rooms required to obtain "good room allocation" can be reduced.



If such i does not exist, output -1 on one line.

Example

Input

5 4
1 2
2 3
3 4
3 5


Output

1
2
#include <map>
#include <algorithm>
#include <iostream>
#define REP(i,n) for(int i=0; i<(int)(n); i++)

#include <queue>
#include <set>
#include <cstdio>
inline int getInt(){ int s; scanf("%d", &s); return s; }

using namespace std;

bool one(double x){
  return x + 1e-9 > 1.0;
}

int main(){
  const int n = getInt();
  const int m = getInt();

  vector<vector<int> > v(n);
  vector<vector<int> > r(n);
  vector<int> intmp;
  vector<int> in(n);
  vector<int> out(n);
  vector<pair<int, int> > e(m);
  map<int, map<int, int> > memo;

  REP(i,m){
    const int a = e[i].first  = getInt() - 1;
    const int b = e[i].second = getInt() - 1;

    v[a].push_back(b);
    in[b]++;

    r[b].push_back(a);
    out[a]++;

    memo[a][b] = memo[b][a] = i;
  }
  intmp = in;

  vector<int> dist(n);
  queue<int> q;

  REP(i,n) if(in[i] == 0){
    q.push(i);
  }

  while(q.size()){
    const int pos = q.front(); q.pop();

    for(const int next : v[pos]){
      dist[next] = max(dist[next], dist[pos] + 1);
      --in[next];
      if(in[next] == 0) q.push(next);
    }
  }

  const int mx = *max_element(dist.begin(), dist.end());
  vector<int> chain(m);
  vector<int> valid(n);

  REP(i,n) if(dist[i] == mx){
    valid[i] = 1;
  }

  REP(i,n) if(out[i] == 0){
    q.push(i);
  }

  while(q.size()){
    const int pos = q.front(); q.pop();

    for(const int next : r[pos]){
      if(dist[pos] == dist[next] + 1){
        if(valid[pos]){
          valid[next] = 1;
          chain[memo[pos][next]] = 1;
        }
      }

      --out[next];
      if(out[next] == 0) q.push(next);
    }
  }

  vector<double> wp(n);
  vector<double> w(m);
  in = intmp;

  int cnt = 0;
  REP(i,n) if(in[i] == 0 && valid[i]){
    cnt++;
  }

  REP(i,n) if(in[i] == 0 && valid[i]){
    wp[i] = 1.0 / cnt;
  }

  REP(i,n) if(in[i] == 0){
    q.push(i);
  }

  while(q.size()){
    const int pos = q.front(); q.pop();

    int cnt = 0;
    for(const int next : v[pos])
      if(chain[memo[pos][next]]) cnt++;

    for(const int next : v[pos]){
      if(chain[memo[pos][next]]){
        wp[next] += wp[pos] / cnt;
        w[memo[pos][next]] += wp[pos] / cnt;
      }
      --in[next];
      if(in[next] == 0) q.push(next);
    }
  }

  bool b = false;
  REP(i,m){
    if(one(w[i])){
      printf("%d\n", i + 1);
      b = true;
    }
  }

  if(!b) puts("-1");

  return 0;
}