//#include //#include //#include #include #include #include #include #include #include #include #include #include #include #include #include #define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0) #define deg(x) cout<< #x"=" << (x) << endl; #define degg(x,y) cout<< #x"="<< (x) <<","<< #y"="<< (y) < pii; typedef pair pll; typedef priority_queue,greater > xqueue; typedef priority_queue dqueue; //typedef tree,rb_tree_tag,tree_order_statistics_node_update> x_rb; //typedef tree,rb_tree_tag,tree_order_statistics_node_update> d_rb; const ll INF=9e18; const int inf=2147483647; ll qpow(ll a,ll b,ll mod) { ll r=1; for(; b; b>>=1) { if(b&1) r=(r*a)%mod; a=(a*a)%mod; } return r; } const int N=2e4+5; int pos[N][105]; vector yes,w[105][15]; set no; void work() { //IOS; int t; sca(t); while(t--) { int n; sca(n); int mx=-1; mes(pos,0); no.clear(); for(int i=0;i<105;i++) { for(int j=0;j<15;j++) w[i][j].clear(); } for(int i=1;i<=n;i++) { int m; sca(m); while(m--) { int tp,p; scaa(tp,p); w[tp][p].PB(i); pos[i][tp]=p; mx=max(mx,tp); } if(i>1) no.insert(i); } yes.clear(); yes.PB(1); for(int i=1;i<=mx;i++) { int m=yes.size(); for(int j=0;j