#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
int t,n;
char a[N],b[N],c[N],d[N];
int main(){
	freopen("edit.in","r",stdin);
	freopen("edit.out","w",stdout);
	scanf("%d",&t);
	while(t--){
		scanf("%d%s%s%s%s",&n,a+1,b+1,c+1,d+1);
		bool flag1=true,flag2=true;
		int sum=0;
		for(int i=2;i<=n;i++) if(a[i]!=a[i-1]) flag1=false;
		for(int i=1;i<=n;i++) if(c[i]!=d[i]) flag2=false;
		if(flag1){
			for(int i=1;i<=n;i++) if(a[i]==b[i]) sum++;
		}else if(flag2){
			for(int i=1;i<=n;i++) if(c[i]=='0'&&a[i]==b[i]) sum++;
			int onea=0,zeroa=0,oneb=0,zerob=0;
			for(int i=1;i<=n;i++){
				if(c[i]=='1'){
					if(a[i]=='1') onea++;
					if(b[i]=='1') oneb++;
					if(a[i]=='0') zeroa++;
					if(b[i]=='0') zerob++;
				}else{
					sum+=min(onea,oneb)+min(zeroa,zerob);
					onea=0,zeroa=0,oneb=0,zerob=0;
				}
			}
			sum+=min(onea,oneb)+min(zeroa,zerob);
		}
		printf("%d\n",sum);
	}
	return 0;
}
