#include<iostream>
#include<cstdio>
#define int long long
using namespace std;
struct node
{
	int l,r,num0,num1,sum;
}a[100002],b[100002];
int t,n,aa[100002],bb[100002],cnta,cntb,cnt1,cnt2,ans;
char s1[100001],s2[100001],s[100001];
signed main()
{
	freopen("edit.in","r",stdin);
	freopen("edit.out","w",stdout); 
	scanf("%lld",&t);
	for(int ll=1;ll<=t;ll++)
	{
		ans=0;
		scanf("%lld",&n);
		scanf("%s",s1+1);
		scanf("%s",s2+1);
		scanf("%s",s+1);
		cnta=0;
		cntb=0;
		for(int i=1;i<=n;i++)
		{
			if(s[i]=='0') aa[++cnta]=i;
		}
		if(aa[cnta]!=n) aa[++cnta]=n+1;
		scanf("%s",s+1);
		for(int i=1;i<=n;i++)
		{
			if(s[i]=='0') bb[++cntb]=i;
		}
		if(bb[cntb]!=n) bb[++cntb]=n+1;
		cnt1=0;
		cnt2=0;
		for(int i=1;i<=cnta;i++)
		{
			if((aa[i]-aa[i-1])>1)
			{
				a[++cnt1].l=aa[i-1]+1;
				a[cnt1].r=aa[i]-1;
				a[cnt1].sum=a[cnt1].r-a[cnt1].l+1;
				a[cnt1].num0=0;
				a[cnt1].num1=0;
				for(int j=a[cnt1].l;j<=a[cnt1].r;j++)
				{
					if(s1[j]=='0') a[cnt1].num0++;
					if(s1[j]=='1') a[cnt1].num1++;
				}
			}
			if(aa[i]!=n+1)
			{
				a[++cnt1].l=aa[i];
				a[cnt1].r=aa[i];
				a[cnt1].sum=a[cnt1].r-a[cnt1].l+1;
				a[cnt1].num0=0;
				a[cnt1].num1=0;
				for(int j=a[cnt1].l;j<=a[cnt1].r;j++)
				{
					if(s1[j]=='0') a[cnt1].num0++;
					if(s1[j]=='1') a[cnt1].num1++;
				}
			}
		}
		for(int i=1;i<=cntb;i++)
		{
			if((bb[i]-bb[i-1])>1)
			{
				b[++cnt2].l=bb[i-1]+1;
				b[cnt2].r=bb[i]-1;
				b[cnt2].sum=b[cnt2].r-b[cnt2].l+1;
				b[cnt2].num0=0;
				b[cnt2].num1=0;
				for(int j=b[cnt2].l;j<=b[cnt2].r;j++)
				{
					if(s2[j]=='0') b[cnt2].num0++;
					if(s2[j]=='1') b[cnt2].num1++;
				}
			}
			if(bb[i]!=n+1)
			{
				b[++cnt2].l=bb[i];
				b[cnt2].r=bb[i];
				b[cnt2].sum=b[cnt2].r-b[cnt2].l+1;
				b[cnt2].num0=0;
				b[cnt2].num1=0;
				for(int j=b[cnt2].l;j<=b[cnt2].r;j++)
				{
					if(s2[j]=='0') b[cnt2].num0++;
					if(s2[j]=='1') b[cnt2].num1++;
				}
			}
		}
		int nwa=1,nwb=1;
		while(true)
		{
			if(nwa>cnt1&&nwb>cnt2) break;
			if(a[nwa].r<=b[nwb].r)
			{
				if(a[nwa].num0>b[nwb].num0)
				{
					ans+=a[nwa].num1+b[nwb].num0;
					b[nwb].num1-=(a[nwa].num1+a[nwa].num0-b[nwb].num0);
					b[nwb].num0=0;
				}else if(a[nwa].num1>b[nwb].num1)
				{
					ans+=a[nwa].num0+b[nwb].num1;
					b[nwb].num0-=(a[nwa].num1+a[nwa].num0-b[nwb].num1);
					b[nwb].num1=0;
				}else
				{
					ans+=a[nwa].num0+a[nwa].num1;
					b[nwb].num1-=a[nwa].num1;
					b[nwb].num0-=a[nwa].num0;
				}
				if(a[nwa].r==b[nwb].r) nwb++;
				nwa++;
			}else
			{
				if(b[nwb].num0>a[nwa].num0)
				{
					ans+=b[nwb].num1+a[nwa].num0;
					a[nwa].num1-=(b[nwb].num1+b[nwb].num0-a[nwa].num0);
					a[nwa].num0=0;
				}else if(b[nwb].num1>a[nwa].num1)
				{
					ans+=b[nwb].num0+a[nwa].num1;
					a[nwa].num0-=(b[nwb].num1+b[nwb].num0-a[nwa].num1);
					a[nwa].num1=0;
				}else
				{
					ans+=b[nwb].num0+b[nwb].num1;
					a[nwa].num1-=b[nwb].num1;
					a[nwa].num0-=b[nwb].num0;
				}
				nwb++;
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}
