// this is the last code before AFO... maybe 
#include<iostream>
#include<string>
using namespace std;
const int N=1e5+5;

bool isz[N];// isZero

int main()
{
	ios::sync_with_stdio(false);
	freopen("edit.in","r",stdin);
	freopen("edit.out","w",stdout);
	int T;
	cin>>T;
	while(T--)
	{
		for(int i=0;i<N;i++)isz[i]=0;
		
		int n;
		cin>>n;
		string s1,s2,t1,t2;
		cin>>s1>>s2>>t1>>t2;
		int ans=0;
		for(int i=0;i<n;i++)
		{
			if(t1[i]=='0' && t2[i]=='0')
			{
				isz[i]=1;
				if(s1[i]==s2[i])ans++;
			}
		}
		int cnt1z=0,cnt1o=0;//cnt s1 zero
		int cnt2z=0,cnt2o=0;//cnt s2 zero
		for(int i=0;i<n;i++)
		{
			if(isz[i]!=1)
			{
				if(s1[i]=='0')cnt1z++;
				else cnt1o++;
			}
		}
		for(int i=0;i<n;i++)
		{
			if(isz[i]!=1)
			{
				if(s2[i]=='0')cnt2z++;
				else cnt2o++;
			}
		}
		
		ans+=min(cnt1z,cnt2z);
		ans+=min(cnt1o,cnt2o);
		cout<<ans<<'\n';
	}
	return 0;
}
