#include <iostream>
#include <stdio.h>
#define MAXNUM 100005
using namespace std;

int T;
int n=0,ans=0,state=0;
char s1[MAXNUM],s2[MAXNUM];
char t1[MAXNUM],t2[MAXNUM];

int getMin(int num1,int num2)
{
	if(num1<num2) return num1;
	return num2;
}


int main()
{
	FILE *fp=fopen("edit.in","r");
	FILE *fl=fopen("edit.out","w");
	fscanf(fp,"%d",&T);
	for(int k=0;k<T;k++)
	{
		n=0,ans=0;
		fscanf(fp,"%d",&n);char tmp;fscanf(fp,"%c",&tmp);
		for(int i=0;i<n;i++) fscanf(fp,"%c",&s1[i]); fscanf(fp,"%c",&tmp);
		for(int i=0;i<n;i++) fscanf(fp,"%c",&s2[i]); fscanf(fp,"%c",&tmp);
		for(int i=0;i<n;i++) fscanf(fp,"%c",&t1[i]); fscanf(fp,"%c",&tmp);
		for(int i=0;i<n;i++) fscanf(fp,"%c",&t2[i]); fscanf(fp,"%c",&tmp);
		
		tmp=s1[0];
		for(int i=1;i<n;i++)
		{
			if(tmp!=s1[i]) break;
			if(i==n-1 && tmp==s1[n-1]) state=1;
		}
		for(int i=0;i<n;i++)
		{
			if(t1[i]!=t2[i]) break;
			if(i==n-1 && t1[n-1]==t2[n-1]) state=2;
		}
		//cout<<s1<<endl<<s2<<endl<<t1<<endl<<t2<<endl<<endl;
		if(state==1)
		{
			int num10=0,num11=0,num20=0,num21=0;
			for(int i=0;i<n;i++)
			{
				if(s1[i]=='1') num11++;
				else num10++;
				if(s2[i]=='1')num21++;// && t2[i]=='0') num21++;
				else if(s2[i]=='0')num20++;// && t2[i]=='0') num20++;
			}
			ans+=getMin(num11,num21)+getMin(num10,num20);
			/*
			if(num11>num21) num11-=num21,ans+=num21;
			else num11=0,ans+=num11;num21=0;
			if(num10>num20) num10-=num20,ans+=num20;
			else num10=n,ans+=num10;num20=0;
			/*for(int i=0;i<n;i++)
			{
				if(s2[i]=='1' && t2[i]=='1') num21++;
				else if(s2[i]=='0' && t2[i]=='1') num20++;
			}*/
		}
		else if(state==2)
		{
			for(int i=0;i<n;i++)
			{
				if(t1[i]=='0' && t2[i]=='0')
				{
					if(s1[i]==s2[i]) ans++;
				}
				else
				{
					int now=i;
					int num10=0,num11=0,num20=0,num21=0;
					while(t1[now]=='1')
					{
						if(s1[now]=='1') num11++;
						else num10++;
						if(s2[now]=='1')num21++;
						else if(s2[now]=='0')num20++;
						now++;
					}
					ans+=getMin(num11,num21)+getMin(num10,num20);
					i=now-1;
				}
			}
		}
		else
		{
			ans=0;
		}
		fprintf(fl,"%d\n",ans);
	}
	/* ！！最后要加上不可交换区间内相同的字符数！！ */
	fclose(fp);
	fclose(fl);
	
	return 0;
}
