#include<bits/stdc++.h>
using namespace std;
int t,ans,n,f;
int a[100100],b[100100],tl[100100],t2[100100];
int tong[2],tong2[2];
char ch;
int main()
{
	freopen("edit.in","r",stdin);
	freopen("edit.out","w",stdout);
	scanf("%d",&t);
	while(t--){
		f=0;
		ans=0;
		scanf("%d",&n);
		for(int i=1;i<=n;i++){
			cin>>ch;
			a[i]=ch-'0';
		}
		for(int i=1;i<=n;i++){
			cin>>ch;
			b[i]=ch-'0';
		}
		for(int i=1;i<=n;i++){
			cin>>ch;
			tl[i]=ch-'0';
		}
		for(int i=1;i<=n;i++){
			cin>>ch;
			t2[i]=ch-'0';
		}
		for(int i=1;i<n;i++){
			if(a[i]!=a[i+1]){
				f=1;
				break;
			}
		}
		if(f==0){
			for(int i=1;i<=n;i++){
				if(a[i]==b[i]) ans++;
			}
			printf("%d\n",ans);
			continue;
		}
		else{
			for(int i=1;i<=n;i++){
				if(tl[i]==1){
					tong[a[i]]++;
					tong2[b[i]]++;
				}
				else{
					int mil=min(tong[0],tong2[0]);
					int mi2=min(tong[1],tong2[1]);
					ans+=mil+mi2;
					for(int i=0;i<=1;i++){
						tong[i]=0;
						tong2[i]=0;
					}
					if(a[i]==b[i]) ans++;
				}
			}
			
		}
		int mil=min(tong[0],tong2[0]);
		int mi2=min(tong[1],tong2[1]);
		ans+=mil+mi2;
		for(int i=0;i<=1;i++){
			tong[i]=0;
			tong2[i]=0;
		}
		printf("%d\n",ans);
	}
	return 0;
}
