#include using namespace std; //Strongly Connected Components #include struct SCC{ int n; vectorcomp,order; vectorused; vector >G,RG; SCC(int _n=0):n(_n),comp(_n,-1),used(_n,false),G(_n),RG(_n){} void add_edge(int from,int to) { G[from].push_back(to); RG[to].push_back(from); } void copy(const vector >&H) { for(int i=0;i=0;i--)if(comp[order[i]]==-1)rdfs(order[i],cnt++); return cnt; } int build(vector >&H) { int ret=build(); H.assign(ret,vector()); for(int i=0;i>N; for(int i=0;i>S[i]; S[i]--; } for(int i=0;i>T[i]; T[i]--; } for(int i=0;i>U[i]; SCC P(N*N*2); for(int i=0;iP[N*N+id]?1:0; } } for(int i=0;i