#include <bits/stdc++.h>
#define ll long long
#define N 100005
using namespace std;
int T,n,ans;
string a,b,c,d;
int cnta1,cnta0,cntb1,cntb0;
void solveA(){
	for(int i=0;i<n;i++)
		if(a[i]==b[i]) ans++; 
	return ;
}
bool tot;
void solveB(){
	for(int i=0;i<n;i++){
		if(c[i]=='0'){
			ans+=min(cnta0,cntb0)+min(cnta1,cntb1); 
			cnta0=cnta1=cntb0=cntb1=0;
			if(a[i]==b[i]) ans++;
			continue;
		}
		if(a[i]=='0') cnta0++;
		else cnta1++;
		if(b[i]=='0') cntb0++;
		else cntb1++;
	}
	ans+=min(cnta0,cntb0)+min(cnta1,cntb1);	
	return ;
}
signed main(){
	freopen("edit.in","r",stdin);
//	freopen("edit2.in","r",stdin);
	freopen("edit.out","w",stdout);
	scanf("%d",&T);
	while(T--){
		scanf("%d",&n);
		cin>>a>>b>>c>>d;
		ans=0;
		cnta0=cnta1=cntb0=cntb1=0;
		tot=1;
		for(int i=1;i<n;i++) if(a[i]!=a[i-1]) tot=0;
		if(tot) solveA();
		else if(c==d) solveB();
		else {
			solveA();
		}
		printf("%d\n",ans);
	}
	return 0;
}
/*  
1
10
0110111100
1111111100
1110000100
0110111011

1
6
011101
111010
110011
110011
*/
