#include using namespace std; int n, m; vector> ikeru; vector del; vector tansaku; int u[350000], v[350000]; int dfs(int i){ tansaku[i] = true; while(!ikeru[i].empty()){ auto jf = ikeru[i].begin(); int j = *jf; if (tansaku[v[j]]){ del[j] = true; ikeru[i].erase(jf); tansaku[i] = false; return v[j]; } int g = dfs(v[j]); if (g != -1 && g != i){ del[j] = true; ikeru[i].erase(jf); tansaku[i] = false; return g; }else if (g == i){ del[j] = true; } ikeru[i].erase(jf); } tansaku[i] = false; return -1; } int main(){ cin >> n >> m; ikeru.resize(n); del.resize(m); tansaku.resize(n); for (int i=0; i> u[i] >> v[i]; u[i]--; v[i]--; ikeru[u[i]].insert(i); } for (int i=0; i> ans; for (int i=0; i