#include<bits/stdc++.h>
#include<cstdio>
using namespace std;
typedef vector<vector<int>> vvi;
const int N=1e5+10;
int T;
int n;
char s1[N],s2[N],t1[N],t2[N];
vvi cnt1(2,vector<int>(2,0)),cnt2(2,vector<int>(2,0));
int ans;
void chg1(vvi& a,vvi& b,int num){
	if(a[1][num]>b[0][num]) ans+=b[0][num],a[1][num]-=b[0][num],b[0][num]=0;
	else ans+=a[1][num],b[0][num]-=a[1][num],a[1][num]=0;
}
int chg2(int num){
	return min(max(cnt1[1][num]-cnt2[0][!num],0),max(cnt2[1][num]-cnt1[0][!num],0));
}
int main()
{
	freopen("edit.in","r",stdin);
	freopen("edit.out","w",stdout);
	scanf("%d",&T);
	while(T--){
		for(int i=0;i<2;i++) for(int j=0;j<2;j++) cnt1[i][j]=cnt2[i][j]=0;
		ans=0;
		scanf("%d %s %s %s %s",&n,s1,s2,t1,t2);	
		for(int i=0;i<n;i++) ans+=(s1[i]==s2[i]);
		for(int i=0;i<n;i++){
			if(t1[i]=='0'&&t2[i]=='0'){
				chg1(cnt1,cnt2,0),chg1(cnt1,cnt2,1),chg1(cnt2,cnt1,0),chg1(cnt2,cnt1,1);
				ans+=chg2(0)+chg2(1);
				for(int i=0;i<2;i++) for(int j=0;j<2;j++) cnt1[i][j]=cnt2[i][j]=0;
				continue;
			}
			if(s1[i]!=s2[i]&&(t1[i]=='1'||t2[i]=='1')) cnt1[t1[i]^'0'][s1[i]^'0']++,cnt2[t2[i]^'0'][s2[i]^'0']++;
		}
		chg1(cnt1,cnt2,0),chg1(cnt1,cnt2,1),chg1(cnt2,cnt1,0),chg1(cnt2,cnt1,1);
		ans+=chg2(0)+chg2(1);
		printf("%d\n",ans);
	}
	return 0;
}
