#include<bits/stdc++.h>
using namespace std;
const int N=2e5+100;
int n,belong1[N],belong2[N];
struct node{int cnt0,cnt1;}a1[N],a2[N];
char s1[N],s2[N];
char t1[N],t2[N]; 
int main(){
	freopen("edit.in","r",stdin);
	freopen("edit.out","w",stdout);
	int T; cin>>T;
	while(T--){
		cin>>n;
		scanf("%s%s",s1+1,s2+1);
		scanf("%s%s",t1+1,t2+1);
		for(int i=0;i<=n+10;i++){
			belong1[i]=belong2[i]=i;
			a1[i].cnt0=a1[i].cnt1=0;
			a2[i].cnt0=a2[i].cnt1=0;
		}
		int now1=0,now2=0;
		for(int i=1;i<=n;i++){
			if(t1[i]=='0'){
				now1=0;
				belong1[i]=i;
			} 
			else{
				if(!now1) now1=i;
				belong1[i]=now1;
			}
			
			if(t2[i]=='0'){
				now2=0;
				belong2[i]=i; 
			}
			else{
				if(!now2) now2=i;
				belong2[i]=now2;
			}
		}
		for(int i=1;i<=n;i++){
			if(s1[i]=='0') a1[belong1[i]].cnt0+=1;
			else a1[belong1[i]].cnt1+=1;
			if(s2[i]=='0') a2[belong2[i]].cnt0+=1;
			else a2[belong2[i]].cnt1+=1;
		}
		int ans=0;
		for(int i=1;i<=n;i++){
			int b1=belong1[i],b2=belong2[i];
			if(a1[b1].cnt0>0 and a2[b2].cnt0>0) ans++,a1[b1].cnt0-=1,a2[b2].cnt0-=1;
			else if(a1[b1].cnt1>0 and a2[b2].cnt1>0) ans++,a1[b1].cnt1-=1,a2[b2].cnt1-=1;
		}
		cout<<ans<<endl;
	}
	return 0;
} 
