#include using namespace std; int n, m; vector> ikeru; vector piv; vector del; vector tansaku; int u[350000], v[350000]; int dfs(int i){ tansaku[i] = true; while(piv[i] < (int)ikeru[i].size()){ int j = ikeru[i][piv[i]]; if (tansaku[v[j]]){ del[j] = true; piv[i]++; tansaku[i] = false; return v[j]; } int g = dfs(v[j]); if (g != -1 && g != i){ del[j] = true; piv[i]++; tansaku[i] = false; return g; }else if (g == i){ del[j] = true; } piv[i]++; } tansaku[i] = false; return -1; } int main(){ cin >> n >> m; ikeru.resize(n); piv.resize(n); del.resize(m); tansaku.resize(n); for (int i=0; i> u[i] >> v[i]; u[i]--; v[i]--; ikeru[u[i]].push_back(i); } for (int i=0; i> ans; for (int i=0; i