#include<bits/stdc++.h>
using namespace std;typedef long long ll;
int read(){int x=0,f=1;char ch;for(;!isdigit(ch=getchar());)if(ch=='-')f=-1;for(;isdigit(ch);ch=getchar())x=x*10+(ch-'0');return x*f;}
namespace Main
{
	const int N=100010;int T,n,m,x,y,z,xx,yy,zz,ans,fa[N<<1],cnt[N<<1][2];char a[N],b[N],c[N],d[N];int find(int x){return fa[x]==x?x:fa[x]=find(fa[x]);}void merge(int x,int y){x=find(x),y=find(y),fa[x]=y,cnt[y][0]+=cnt[x][0],cnt[y][1]+=cnt[x][1];}
	void solve(){cin>>n>>(a+1)>>(b+1)>>(c+1)>>(d+1),ans=0,m=n*2;for(int i=1;i<=m;++i)fa[i]=i,cnt[i][0]=cnt[i][1]=0;for(int i=1;i<=n;++i)++cnt[i][a[i]-'0'],++cnt[i+n][b[i]-'0'];
	for(int i=1;i<n;++i){if(c[i]=='1'&&c[i+1]=='1')merge(i,i+1);if(d[i]=='1'&&d[i+1]=='1')merge(i+n,i+n+1);}
	for(int i=1;i<=n;++i)if(c[i]=='0'&&d[i]=='0')ans+=(a[i]==b[i]);else if(c[i]=='1'&&d[i]=='0'){x=find(i),y=b[i]-'0';if(cnt[x][y])--cnt[x][y],++ans;else --cnt[x][!y];}
	else if(c[i]=='0'&&d[i]=='1'){x=find(i+n),y=a[i]-'0';if(cnt[x][y])--cnt[x][y],++ans;else --cnt[x][!y];}
	for(int i=1;i<=n;++i)if(c[i]=='1'&&d[i]=='1'){x=find(i),y=find(i+n),z=0;for(int j=0;j<2;++j)if(cnt[x][j]&&cnt[y][j]){z=1,--cnt[x][j],--cnt[y][j];break;}if(z)++ans;else --cnt[x][!cnt[x][0]],--cnt[y][!cnt[y][0]];}
	cout<<ans<<endl;}
	void main()
	{
		ios::sync_with_stdio(0),cin.tie(0),cout.tie(0),cin>>T;
		for(;T--;)solve();
	}
}
int main()
{
	freopen("edit.in","r",stdin);
	freopen("edit.out","w",stdout);
	Main::main();
	return 0;
}
