#include #include #include using namespace std; using ll = long long; using ull = unsigned long long; #define rep(i,n) for(int i=0; i<(n); i++) using mll = atcoder::modint998244353; int N,M; vector> E; vector inIdx; vector I; vector F; void testcase(){ cin >> N >> M; E.resize(N); inIdx.assign(N,0); F.assign(N,0); rep(i,M){ int u,v; cin >> u >> v; u--; v--; E[u].push_back(v); inIdx[v]++; F[u] = F[v] = 1; } rep(i,N) if(inIdx[i] == 0) if(F[i]) I.push_back(i); for(int i=0; i