#include using namespace std; //#include //using namespace atcoder; using ll = long long; using ull = unsigned long long; #define rep(i,n) for(int i=0;i<(n);++i) int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; vector> g(n); for(int i=0;i> m; for(int j=0;j> v; --v; g[i].emplace_back(v); } } vector seen(n); auto dfs = [&] (auto dfs,int v) -> void{ seen[v] = true; for(auto next : g[v]){ if(seen[next])continue; dfs(dfs,next); } }; dfs(dfs,0); for(int i=0;i