#include<bits/stdc++.h>
using namespace std;
int n,a[100005],b[100005],bj1[100005],bj2[100005];
signed main()
{
	freopen("edit.in","r",stdin);
	freopen("edit.out","w",stdout);
	int T;
	scanf("%d",&T);
	while(T--)
	{
		int bjA=0,bjC1=0,bjC2=0,s=0;
		scanf("%d",&n);
		getchar();
		for(int i=1;i<=n;i++)
		{
			a[i]=getchar()-'0';
			if(a[i]!=a[i-1]&&i!=1) bjA=1;
		}
		getchar();
		for(int i=1;i<=n;i++)
		{
			b[i]=getchar()-'0';
			if(b[i]==a[i]) s++;
		}
		getchar();
		for(int i=1;i<=n;i++)
		{
			bj1[i]=getchar()-'0';
			bjC1+=(1-bj1[i]);
		}
		getchar();
		for(int i=1;i<=n;i++)
		{
			bj2[i]=getchar()-'0';
			bjC2+=(1-bj2[i]);
		}
		getchar();
		if(bjA==0)
		{
			printf("%d\n",s);
		}
	}
	return 0;
}
