#include using namespace std; const int N=1e5+10; int T,n,ans=0; string s1,s2,t1,t2; int ok[2][2]; int main(){ freopen("edit.in","r",stdin); freopen("edit.out","w",stdout); ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); cin>>T; while(T--){ ans=0; memset(ok,0,sizeof(ok)); cin>>n; cin>>s1>>s2>>t1>>t2; s1=" "+s1,s2=" "+s2,t1=" "+t1,t2=" "+t2; for(int i=1,j=1;;){ while(i<=n&&t1[i]!='0'){ ok[0][s1[i]-'0']++; i++; } while(j<=n&&t2[j]!='0'){ ok[1][s2[j]-'0']++; j++; } if(ij){ ok[1][s2[j]-'0']++; int res0=min(ok[0][0],ok[1][0]),res1=min(ok[0][1],ok[1][1]); ans+=res0+res1; ok[0][0]=ok[0][0]-res0; ok[0][1]=ok[0][1]-res1; ok[1][0]=ok[1][0]-res0; ok[1][1]=ok[1][1]-res1; if(ok[1][0]) ok[0][1]-=ok[1][0]; if(ok[1][1]) ok[0][0]-=ok[1][1]; ok[1][0]=ok[1][1]=0; j++; } else{ ans+=min(ok[0][0],ok[1][0])+min(ok[0][1],ok[1][1]); if(i>n) break; ans+=(s1[i]==s2[j]); ok[0][0]=ok[0][1]=ok[1][0]=ok[1][1]=0; i++,j++; } } cout<