#include<bits/stdc++.h> 
#define ri register int
#define ll long long
#define mkp make_pair
using namespace std;
const int maxn=1e5+7;
int n;
char s1[maxn],s2[maxn],t1[maxn],t2[maxn];
pair<int,int>seq1[maxn],seq2[maxn];
int tot1,tot2;
int num1[2][maxn],num2[2][maxn];
const int inf=1e9;
void solve(){
	cin>>n;
	for(ri i=1;i<=n;i++)cin>>s1[i];
	for(ri i=1;i<=n;i++)cin>>s2[i];
	for(ri i=1;i<=n;i++)cin>>t1[i];
	for(ri i=1;i<=n;i++)cin>>t2[i];
	int ans=0;
	tot1=0;
	for(ri i=1;i<=n;i++){
		if(t1[i]=='0'){
			seq1[++tot1]=mkp(i,i);
			continue;
		}
		int j=i;
		while(j+1<=n&&t1[j+1]!='0')j++;
		seq1[++tot1]=mkp(i,j);
		i=j;
	}
	tot2=0;
	for(ri i=1;i<=n;i++){
		if(t2[i]=='0'){
			seq2[++tot2]=mkp(i,i);
			continue;
		}
		int j=i;
		while(j+1<=n&&t2[j+1]!='0')j++;
		seq2[++tot2]=mkp(i,j);
		i=j;
	}
//	cout<<tot1<<' '<<tot2<<endl;
//	for(ri i=1;i<=tot1;i++)cout<<'('<<seq1[i].first<<','<<seq1[i].second<<')' ;cout<<endl;
//	for(ri i=1;i<=tot2;i++)cout<<'('<<seq2[i].first<<','<<seq2[i].second<<')' ;cout<<endl;
	for(ri i=1;i<=tot1;i++){
		num1[0][i]=num1[1][i]=0;
		for(ri j=seq1[i].first;j<=seq1[i].second;j++){
			num1[s1[j]-'0'][i]++;
		}
	}
	for(ri i=1;i<=tot2;i++){
		num2[0][i]=num2[1][i]=0;
		for(ri j=seq2[i].first;j<=seq2[i].second;j++){
			num2[s2[j]-'0'][i]++;
		}
	}
//	for(ri i=1;i<=tot1;i++)cout<<'('<<num1[0][i]<<','<<num1[1][i]<<')' ;cout<<endl;
//	for(ri i=1;i<=tot1;i++)cout<<'('<<num2[0][i]<<','<<num2[1][i]<<')' ;cout<<endl;
	for(ri i=1;i<=n;i++){
		int pos1=upper_bound(seq1+1,seq1+tot1+1,mkp(i,inf))-seq1-1;
		int pos2=upper_bound(seq2+1,seq2+tot2+1,mkp(i,inf))-seq2-1;
		int t;
		t=min(min(num1[0][pos1],num2[0][pos2]),1);
		num1[0][pos1]-=t;
		num2[0][pos2]-=t;
//		if(t!=0)cout<<pos1<<' '<<pos2<<' '<<ans<<endl; 
		ans+=t;
		t=min(min(num1[1][pos1],num2[1][pos2]),1);
		num1[1][pos1]-=t;
		num2[1][pos2]-=t;
		ans+=t;
//		if(t!=0)
//		cout<<pos1<<' '<<pos2<<' '<<ans<<endl; 
	}
	cout<<ans<<endl;
}
signed main(){
	freopen("edit.in","r",stdin);
	freopen("edit.out","w",stdout);
	ios::sync_with_stdio(0);
	int T;cin>>T;
	while(T--)solve();
	return 0;
}
/*

1
6
011101
111010
111010
101101

*/
