#include using namespace std; #include using namespace atcoder; using mint=modint998244353; //1000000007; using ll=long long; using pp=pair; #define sr string #define vc vector #define fi first #define se second #define rep(i,n) for(int i=0;i<(int)n;i++) #define pb push_back #define all(v) v.begin(),v.end() #define pque priority_queue #define bpc(a) __builtin_popcount(a) int main(){ int n,q;cin>>n>>q; vc v(n,vc(0)); rep(i,q){ int a,b;cin>>a>>b; a--; b--; v[a].pb({b,i}); } int ac=q+1,wa=0; while(ac-wa>1){ int x=(ac+wa)/2; vcc(n,0); bool ok=false; auto f=[&](auto f,int a)->void{ c[a]=1; for(auto [au,i]:v[a])if(i