//多测不清空，十年OI一场空
#include<bits/stdc++.h>
#include<algorithm>
#include<queue>
#include<cstring>
#include<string>
using namespace std;
const int maxn=100050;
int read();
int readc();
int readd();
void workA();
void workB();
//void work();
int T,n;int s1[maxn],s2[maxn],t1[maxn],t2[maxn],cnt11[maxn],cnt21[maxn],cnt10[maxn],cnt20[maxn];
queue<int>q1,q2;
int main()
{
	freopen("edit.in","r",stdin);
	freopen("edit.out","w",stdout);
	T=read();
	
	for(int e=1;e<=T;e++)
	{
		n=read();
		memset(s1,0,sizeof(s1));
		memset(s2,0,sizeof(s2));
		memset(t1,0,sizeof(t1));
		memset(t2,0,sizeof(t2));
		memset(cnt11,0,sizeof(cnt11));
		memset(cnt21,0,sizeof(cnt21));
		memset(cnt10,0,sizeof(cnt10));
		memset(cnt20,0,sizeof(cnt20));
		//q1.clear();q2.clear();
		for(int i=1;i<=n;i++) s1[i]=readc()-48;
		for(int i=1;i<=n;i++) s2[i]=readc()-48;
		for(int i=1;i<=n;i++) t1[i]=readc()-48;
		for(int i=1;i<=n;i++) t2[i]=readc()-48;
		//for(int i=1;i<=n;i++) printf("%d",s1[i]);
		for(int i=1;i<=n;i++)
		{
			if(!t1[i]) q1.push(i);
		}
		for(int i=1;i<=n;i++)
		{
			if(!t2[i]) q2.push(i);
		}
		bool flag=true;
		for(int i=2;i<=n;i++){if(s1[i]!=s1[i-1]){flag=false;break;}}
		if(flag==true) {workA();continue;}
		bool fb=true;
		for(int i=1;i<=n;i++){if(t1[i]!=t2[i]){fb=false;break;}}
		if(fb==true) {workB();continue;}
		//work();
		printf("100\n");
	}
	return 0;
}
int readd()
{
	int x=0,f=0;char ch=getchar();
	while(!isdigit(ch)){f|=ch=='-';ch=getchar();}
	while(isdigit(ch)){x=(x<<3)+(x<<1)+(ch^48);}
	return x;
}
int read()
{
	int x=0,f=0;char ch=getchar();
	while(!isdigit(ch)){f|=ch=='-';ch=getchar();}
	while(isdigit(ch)){x=(x<<3)+(x<<1)+(ch^48);ch=getchar();}
	return x;
}
int readc()
{
	char ch=getchar();
	while((ch==' ')||(ch=='\n')||(ch=='\r')) ch=getchar();
	return ch;
}
void workA()
{
	int cnt=0;
	for(int i=1;i<=n;i++) cnt+=s2[i];
	if(s1[1]==1) printf("%d\n",cnt);
	else printf("%d\n",n-cnt);
}
void workB()
{
	int cnt=0,cnt1=0,cnt2=0;
	for(int i=1;i<=n;i++)
	{
		if(t1[i]==0){if(s1[i]!=s2[i])cnt++;cnt+=max(cnt1,cnt2)-min(cnt1,cnt2);cnt1=cnt2=0;continue;}
		if(s1[i]==1) cnt1++;
		if(s2[i]==1) cnt2++;
	}
	cnt+=max(cnt1,cnt2)-min(cnt1,cnt2);
	printf("%d\n",n-cnt);
}
/*
void work()
{
	int cnt=0;
	int si1=q1.size(),si2=q2.size();
	int p1=0,p2=0;
	for(int i=0;i<si1;i++)
	{
	//	for(int j=i-1<0?1:q1[i-1];j<q1[i];j++) if(s1[j]) cnt11[i]++ else cnt10[i]++;		
	}
	
	for(int i=q1[si1-1]+1;i<=n;i++)  if(s1[i]) cnt11[si1]++ else cnt10[si1]++;
	for(int i=q2[si2-1]+1;i<=n;i++)  if(s2[i]) cnt21[si1]++ else cnt20[si1]++;
	for(int i=0;i<si2;i++)
	{
		for(int j=i-1<0?1:q2[i-1];j<q2[i];j++) if(s2[j]) cnt21[i]++ else cnt20[i]++;		
	}
	while(p1<si1||p2<si2)
	{
		if(q1[p1]<q2[p2]) 
		{
			if(cnt11[p1]>cnt21[p2]) 
			{
				cnt21[p2]=0;
				cnt+=cnt11[p1];
			}
		}
	}
	printf("%d\n",cnt)
}
*/
















