#include<bits/stdc++.h>
using namespace std;
const int MAXN=1e5+10;
int T;
int n;
int a[MAXN],b[MAXN];
string as,bs,v1s,v2s;
int vis1[MAXN],vis2[MAXN];
int l,r;
int ans=0;
int za,oa,zb,ob;
int main()
{
	freopen("edit.in","r",stdin);
	freopen("edit.out","w",stdout);
	scanf("%d",&T);
	while(T--)
	{
		l=1;
		r=0;
		ans=0;
		cin>>n;
		cin>>as>>bs>>v1s>>v2s;
		for(int i=1;i<=n;i++)
		{
			a[i]=as[i-1]-'0';
			b[i]=bs[i-1]-'0';
			a[i]+=a[i-1];
			b[i]+=b[i-1]; 
			vis1[i]=v1s[i-1]-'0';
			vis2[i]=v2s[i-1]-'0';
		}
		for(int i=1;i<=n;i++)
		{
			if(((vis1[i]==vis1[i-1]||vis2[i]==vis2[i-1])&&(vis1[i]+vis2[i]>=1&&vis1[i-1]+vis2[i-1]>=1))||(i==1&&vis1[i]+vis2[i]>=1&&vis1[i-1]+vis2[i-1]>=1))
				r=i;
			else
			{
				oa=a[r]-a[l-1];
				za=r-l+1-oa;
				ob=b[r]-b[l-1];
				zb=r-l+1-ob;
				ans+=min(oa,ob)+min(za,zb);
				l=i;
				r=i;
			}
		}
		oa=a[r]-a[l-1];
		za=r-l+1-oa;
		ob=b[r]-b[l-1];
		zb=r-l+1-ob;
		ans+=min(oa,ob)+min(za,zb);
		cout<<ans<<"\n";
	}
	fclose(stdin);
	fclose(stdout);
	return 0;
 } 
