#include<bits/stdc++.h>
using namespace std;
int t,n,bl1[100010],bl2[100010],cnt,ans;
pair<int,int> ct1[100010],ct2[100010];
char s1[100010],s2[100010],t1[100010],t2[100010];
int read()
{
	int r=0,w=1;
	char ch=getchar();
	while(ch<'0'||ch>'9') w=ch=='-'?-1:w,ch=getchar();
	while(ch>='0'&&ch<='9') r=r*10+ch-'0',ch=getchar();
	return r*w;
}
int main()
{
	freopen("edit.in","r",stdin);
	freopen("edit.out","w",stdout);
	t=read();
	while(t--)
	{
		memset(bl1,0,sizeof(bl1));
		memset(bl2,0,sizeof(bl2));
		memset(ct1,0,sizeof(ct1));
		memset(ct2,0,sizeof(ct2));
		n=read();
		scanf("%s%s%s%s",s1+1,s2+1,t1+1,t2+1);
		cnt=0;
		for(int i=1;i<=n;i++)
		{
			if(t1[i-1]!='1'||t1[i]=='0')
			++cnt;
			bl1[i]=cnt;
			if(s1[i]=='1')
			ct1[cnt].second++;
			else
			ct1[cnt].first++;
		}
		ans=cnt=0;
		for(int i=1;i<=n;i++)
		{
			if(t2[i-1]!='1'||t2[i]=='0')
			++cnt;
			bl2[i]=cnt;
			if(s2[i]=='1')
			ct2[cnt].second++;
			else
			ct2[cnt].first++;
		}
		for(int i=1;i<=n;i++)
		if(ct1[bl1[i]].first&&ct2[bl2[i]].first)
		ans++,ct1[bl1[i]].first--,ct2[bl2[i]].first--;
		else if(ct1[bl1[i]].second&&ct2[bl2[i]].second)
		ans++,ct1[bl1[i]].second--,ct2[bl2[i]].second--;
		else if(ct1[bl1[i]].first)
		ct1[bl1[i]].first--,ct2[bl2[i]].second--;
		else
		ct1[bl1[i]].second--,ct2[bl2[i]].first--;
		printf("%d\n",ans);
	}
} 
