#include using namespace std; const int N=2e5+17; namespace yywh{ int n; bitsets1,s2,t1,t2; int grop[2][N],gp1,gp2; struct node{ int a,b; }edge[2][N]; int ans; int work(){ int T; cin>>T; while(T--){ cin>>n; cin>>s1>>s2; cin>>t1; gp1=0; for(int i=0;i>t2; gp2=0; for(int i=0;i0&&edge[1][grop[1][i]].a>0){ edge[0][grop[0][i]].a--; ans++; edge[1][grop[1][i]].a--; }else if(edge[1][grop[1][i]].b>0&&edge[0][grop[0][i]].b>0){ edge[1][grop[1][i]].b--; ans++; edge[0][grop[0][i]].b--; } } cout<