#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define vi vector<int>
#define pb push_back
#define lowbit(x) x&-x
using namespace std;
const int N=1e5+10;
int ans;
char ch[N];
pii v1[N],v2[N];
int n,m,T,a[N],b[N],t1[N],t2[N];
inline int read(){
	int s=0,f=0;
	char ch=getchar();
	while(ch<'0'||ch>'9') f|=(ch=='-'),ch=getchar();
	while(ch<='9'&&ch>='0') s=(s<<3)+(s<<1)+(ch^48),ch=getchar();
	return f?-s:s;
}
inline pii operator + (pii x,pii y){
	return {x.first+y.first,x.second+y.second};
}
int main(){
	freopen("edit.in","r",stdin);
	freopen("edit.out","w",stdout);
	T=read();
	while(T--){
		n=read();
		scanf("%s",ch+1);for(register int i=1;i<=n;++i) a[i]=ch[i]-'0';
		scanf("%s",ch+1);for(register int i=1;i<=n;++i) b[i]=ch[i]-'0';
		scanf("%s",ch+1);for(register int i=1;i<=n;++i) t1[i]=ch[i]-'0';
		scanf("%s",ch+1);for(register int i=1;i<=n;++i) t2[i]=ch[i]-'0';
		for(register int i=1;i<=n;++i) v1[i]={0,0},v2[i]={0,0};
		for(register int i=1;i<=n;++i){
			v1[i]={!a[i],a[i]};
			if(!t1[i]) continue;
			int j=i;
			while(j<n&&t1[j+1]){
				++j;
				v1[i]=v1[i]+(pii){!a[j],a[j]};
			}
			i=j;
		}
		for(register int i=1;i<=n;++i){
			v2[i]={!b[i],b[i]};
			if(!t2[i]) continue;
			int j=i;
			while(j<n&&t2[j+1]){
				++j;
				v2[i]=v2[i]+(pii){!b[j],b[j]};
			}
			i=j;
		}
		pii l=(pii){0,0},r=(pii){0,0};ans=0;
		for(register int i=1;i<=n;++i){
			l=l+v1[i];r=r+v2[i];
			if(l.first&&r.first){
				++ans;
				--l.first,--r.first;
			}else if(l.second&&r.second){
				++ans;
				--l.second,--r.second;
			}else{
				if(l.first) --l.first,--r.second;
				else --l.second,--r.first;
			}
		}
		cout<<ans<<'\n';
	}
	return 0;
}
