#include<bits/stdc++.h>
#define ll long long
#define fo(x,a,b) for(register int (x)=(a);(x)<=(b);++(x)) 
#define fr(x,a,b) for(register int (x)=(a);(x)>=(b);--(x)) 
using namespace std;
const int M=1e5+6;
int n,sum1[M],sum2[M];
char s1[M],s2[M],t1[M],t2[M];
void solvef(){
	
}
void solveA(){
	if(!sum1[n])cout<<n-sum2[n]<<"\n";
	else if(sum1[n]==n)cout<<sum2[n]<<"\n";
}
void solveB(){
	bool is=0;
	fo(i,1,n){
		if(t1[i]!=t2[i]){is=1;break;}
	}
	if(!is){
		int cnt,ans=0;
		bool ct=0;
		fo(i,1,n){
			if(!ct&&t1[i]=='1'){
				if(i!=n&&t1[i+1]=='0'){
					if(s1[i]==s2[i])ans++;
					continue; 
				}else if(i==n)if(s1[i]==s2[i])ans++;
				cnt=i;
				ct=1;
			}else if(ct&&(t1[i]=='0'||i==n)){
				if(i==n) ans+=i-cnt+1-abs(sum1[i]-sum1[cnt-1]-sum2[i]+sum2[cnt-1]);
				else ans+=i-cnt-abs(sum1[i-1]-sum1[cnt-1]-sum2[i-1]+sum2[cnt-1]);
				ct=0;
			}
			if(!ct&&t1[i]=='0'){
				if(s1[i]==s2[i])ans++;
			}
		}
		cout<<ans<<"\n";
	}
}
void solvef(){
	
}
int main()
{
	freopen("edit.in","r",stdin);
	freopen("edit.out","w",stdout);
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	int t;
	cin>>t;
	while(t--){
		cin>>n;
		fo(i,1,n){
			cin>>s1[i];
			sum1[i]=sum1[i-1]+(s1[i]-'0');
		}fo(i,1,n){
			cin>>s2[i];
			sum2[i]=sum2[i-1]+(s2[i]-'0');
		}fo(i,1,n){
			cin>>t1[i];
		}fo(i,1,n){
			cin>>t2[i];
		}
		if(n<=10){
			solvef();
		}else{
			solveA();
			solveB();
		}
	}
	
	return 0;
}

