#include<cstdio>
#include<iostream>
#include<cmath>
#include<cstring>
using namespace std;
#define Maxn (int)(5e5+10)

int s1[Maxn];
int s2[Maxn];
int a[Maxn],b[Maxn];

int main(){
	freopen("edit.in","r",stdin);
	freopen("edit.out","w",stdout);
	int T;
	scanf("%d",&T);//打特殊性质先！ 
	while(T--){
		int n;
		scanf("%d",&n);
		int chk=0;
		int chk2=1;
		string c;
		cin>>c;
		for(int i=0;i<n;i++){
			s1[i]=c[i]-'0';
			if(i==1) chk=s1[0];
			else if(s1[i]!=chk){
				chk=-1;
			}
		}
		cin>>c;
		for(int i=0;i<n;i++){
			s2[i]=c[i]-'0';
		}
		cin>>c;
		for(int i=0;i<n;i++){
			a[i]=c[i]-'0';
		}
		cin>>c;
		for(int i=0;i<n;i++){
			b[i]=c[i]-'0';
			if(b[i]!=a[i]) chk2=-1;
		}
		if(chk!=-1){//特殊性质1 
			int ans=0;
			for(int i=0;i<n;i++){
				if(s2[i]==chk){
					ans++; 
				}
			}
			printf("%d\n",ans);
			continue;
		}
		else if(chk2!=-1){//特殊性质2 
			int af0=0,af1=0,bf0=0,bf1=0;
			int ans=0;
			for(int i=0;i<n;i++){
				if(a[i]==b[i]&&a[i]==0){
					ans+=min(af0,bf0);
					ans+=min(af1,bf1);
					af0=0;af1=0;bf0=0;bf1=0;
					if(s1[i]==s2[i]){
						ans++;
					}
					continue;
				}
				if(s1[i]==0) af0++;
				if(s1[i]==1) af1++;
				if(s2[i]==0) bf0++;
				if(s2[i]==1) bf1++;
			}
			ans+=min(af0,bf0);
			ans+=min(af1,bf1);
			printf("%d\n",ans);
			continue;
		}
//		else{//特殊性质3 
//			
//		} 
	}
	return 0;
} 
