//edit
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
int T,n,ans;
int vis[N],sfn1,sfn0,ssn1,ssn0;
int sf0[N],sf1[N],cntf0,cntf1;
int ss0[N],ss1[N],cnts0,cnts1;

int read(){
	int x=0,k=1;char c=getchar();
	while(c<'0'||c>'9'){
		if(c=='-') k=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9'){
		x=(x<<1)+(x<<3)+(c^48);
		c=getchar();
	}
	return x*k;
}

int main()
{
	freopen("edit.in","r",stdin);
	freopen("edit.out","w",stdout);
	T=read();
	while(T--){
		ans=0;
		sfn1=0,sfn0=0,ssn1=0,ssn0=0;
		cntf0=0,cntf1=0;
		cnts0=0,cnts1=0;
		//memset(vis,0,sizeof(vis));
		memset(sf0,0,sizeof(sf0));
		memset(sf1,0,sizeof(sf1));
		memset(ss0,0,sizeof(sf0));
		memset(ss1,0,sizeof(sf1));
		
		//多测清空 
		n=read();
		string s1,s2,t1,t2;
		cin>>s1>>s2>>t1>>t2;
		for(int i=0;i<n;i++){
			if(s1[i]==s2[i])//未更改时已经符合条件，可证明其优 
				ans++;
			else{//不符合条件，需要移动更改 
				if(t1[i]=='1')
					if(s1[i]=='0') sfn0++,sf0[++cntf0]=i;
					else sfn1++,sf1[++cntf1]=i;
				if(t2[i]=='1')
					if(s2[i]=='0') ssn0++,ss0[++cnts0]=i;
					else ssn1++,ss1[++cnts1]=i;
			}
		}
		//先对s1进行操作
		int x=min(sfn0,sfn1);
		if(x==sfn0) for(int i=1;i<=cntf0;i++) vis[sf0[i]]=1;
		else for(int i=1;i<=cntf1;i++) vis[sf1[i]]=1;
		ans+=x*2;
		//对s2进行操作 
		for(int i=1;i<=cnts0;i++) if(vis[ss0[i]]) ssn0--;
		for(int i=1;i<=cnts1;i++) if(vis[ss1[i]]) ssn1--;
		x=min(ssn0,ssn1);
		ans+=x*2;
		printf("%d\n",ans);
	}
	return 0;
}

