#include<bits/stdc++.h>
#define Ri register int 
using namespace std;
const int N=2e5+15;
int n;
char s1[N],s2[N],t1[N],t2[N];
void get1(int &x,int &y,int wei){
	if(t1[wei]=='0'){
		if(s1[wei]=='0') x++;
		else y++;
		return ;
	}
	for(Ri i=wei; i<=n; ++i){
		if(t1[i]=='0') break;
		if(s1[i]=='0') x++;
		else y++;
	}
	return ;
}
void get2(int &x,int &y,int wei){
	if(t2[wei]=='0'){
		if(s2[wei]=='0') x++;
		else y++;
		return ;
	}
	for(Ri i=wei; i<=n; ++i){
		if(t2[i]=='0') break;
		if(s2[i]=='0') x++;
		else y++;
	}
	return ;
}
void Sol(){
	scanf("%d",&n);
	scanf("%s",s1+1);
	scanf("%s",s2+1);
	scanf("%s",t1+1);
	scanf("%s",t2+1);
	t1[0]=t1[n+1]=t2[0]=t2[n+1]='0';
	int A=0,B=0,C=0,D=0,ans=0;
	for(Ri i=1; i<=n; ++i){
		if(A==0 && B==0) get1(A,B,i);
		if(C==0 && D==0) get2(C,D,i);
		if(A>0 && C>0) ans++,A--,C--;
		else{
			if(B>0 && D>0) ans++,B--,D--;
			else{
				if(A>0) A--;
				if(B>0) B--;
				if(C>0) C--;
				if(D>0) D--;
			}
		}
	}
	printf("%d\n",ans);
}
int main(){
	freopen("edit.in","r",stdin);
	freopen("edit.out","w",stdout);
	int T;
	scanf("%d",&T);
	while(T--) Sol();
}
