#include <iostream>
#include <cstdio>
#include <string>
#include <bitset>
#include <algorithm>
using namespace std;
#define MAXN 100005
int T,n,ans;
int cnt1[2],cnt2[2],cnt3[2],cnt4[2];
string s1,s2,t1,t2;
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0),cout.tie(0);
	freopen("edit.in","r",stdin);
	freopen("edit.out","w",stdout);
	cin>>T;
	while(T--)
	{
		cnt1[0]=cnt1[1]=cnt2[0]=cnt2[1]=cnt3[0]=cnt3[1]=cnt4[0]=cnt4[1]=0;
		ans=0;
		cin>>n;
		cin>>s1>>s2>>t1>>t2;
		bitset<MAXN> bs1(s1),bs2(s2),bt1(t1),bt2(t2);
		for(int i=0;i<n;i++)
		{
			cnt1[s1[i]-'0']++;
			cnt2[s2[i]-'0']++;
			cnt3[t1[i]-'0']++;
			cnt4[t2[i]-'0']++;
		}
		// 骗分导论
		if(cnt1[0]==n)
		{
			for(int i=0;i<n;i++)ans+=(s2[i]=='0');
		}
		else if(cnt1[1]==n)
		{
			for(int i=0;i<n;i++)ans+=(s2[i]=='1');
		}
		else if(t1==t2)
		{
			int cnta[2]={0,0},cntb[2]={0,0};
			for(int i=0;i<n;i++)
			{
				if(t1[i]=='0'&&t2[i]=='0')
				{
					if(s1[i]==s2[i])ans++;
					ans+=min(cnta[0],cntb[0])+min(cnta[1],cntb[1]);
					cnta[0]=cnta[1]=cntb[0]=cntb[1]=0;
				}
				else
				{
					cnta[s1[i]-'0']++;
					cntb[s2[i]-'0']++;
				}
			}
		}
		else
		{
			for(int i=0;i<n;i++)
			{
				ans+=(s1[i]==s2[i]);
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}
