#include //#include using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) //using namespace atcoder; typedef long long ll; const ll INF = 1e18; //typedef modint998244353 mint; //cout << fixed << setprecision(12); int main(){ int n, q; cin >> n >> q; vector qx(q); vector qy(q); for (int i=0; i> qx[i] >> qy[i]; qx[i]--; qy[i]--; } int suki = q+1, kirai = -1; while (suki - kirai > 1){ int targ = (suki + kirai) / 2; vector> ikeru(n, vector(0)); vector deg(n); for (int i=0; i mada(0); for (int i=0; i 0){ mode = true; break; } } if (mode) suki = targ; else kirai = targ; } if (suki == q+1){ cout << -1 << endl; }else{ cout << suki << endl; } }