#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
typedef pair<pii,int> piii;
int T,n;
string s,t,v,w;
int zf[100002],zfc[100002];//s1,s2
int kh[100002],khc[100002];//t1,t2
int qzh[10002],qzhc[100002];
vector<pii> qj,qjc;
vector<piii> rc,rcc;
int main()
{
	freopen("edit.in","r",stdin);
	freopen("edit.out","w",stdout);
	scanf("%d",&T);
	while(T--)
	{
		for(int i=1;i<=n;i++)
		{
			zf[i]=0;
			zfc[i]=0;
			kh[i]=0;
			khc[i]=0;
			qzh[i]=qzhc[i]=0;
		}
		qj.clear(),qjc.clear();
		rc.clear(),rcc.clear();
		scanf("%d",&n);
		cin>>s>>t>>v>>w;
		int ctr=0,ctrc=0;
		if(T!=3)
		{
			continue;
		}
		for(int i=1;i<=n;i++)
		{
			zf[i]=(s[i-1]-'0');
			zfc[i]=(t[i-1]-'0');
			kh[i]=v[i-1]-'0';
			khc[i]=w[i-1]-'0';
			ctr+=(zf[i]==zf[1]);
			ctrc+=(zfc[i]==zfc[1]);
			qzh[i]=qzh[i-1]+zf[i];
			qzhc[i]=qzhc[i-1]+zfc[i];
		}
		cout<<ctr<<" "<<ctrc<<endl;
		if(ctr==n)
		{
			ctrc=0;
			for(int i=1;i<=n;i++)
			{
				ctrc+=(zfc[i]==zf[1]);
			}
			printf("%d\n",ctrc);
			continue;
		}
		int rct=-1,rctc=-1,lst=-1,lstc=-1;
		int cnt[2]={0,0},cntc[2]={0,0};
		for(int i=1;i<=n;i++)
		{
			if(kh[i]!=rct)
			{
				qj.push_back(make_pair(lst,i-1));
				rc.push_back(make_pair(make_pair(cnt[0],cnt[1]),kh[i-1]));
				lst=i;
				rct=kh[i];
				cnt[0]=cnt[1]=0;
			}
			if(khc[i]!=rctc)
			{
				qjc.push_back(make_pair(lstc,i-1));
				rcc.push_back(make_pair(make_pair(cntc[0],cntc[1]),khc[i-1]));
				lstc=i;
				rctc=khc[i];
				cntc[0]=cntc[1]=0;
			}
			cnt[zf[i]]++;
			cntc[zfc[i]]++;
		}
		qj.push_back(make_pair(lst,n));
		rc.push_back(make_pair(make_pair(cnt[0],cnt[1]),kh[n]));
		qjc.push_back(make_pair(lstc,n));
		rcc.push_back(make_pair(make_pair(cntc[0],cntc[1]),khc[n]));
		int ptr=1,ptrc=1;
		int ans=0;
		int tt=qj[ptr].second,ttc=qjc[ptrc].second;
		while(ptr<qj.size()&&ptrc<qjc.size())
		{
			if(rc[ptr].second==0&&rcc[ptrc].second==0)
			{
				for(int i=max(qj[ptr].first,qjc[ptrc].first);i<=min(tt,ttc);i++)
				{
					if(zf[i]==zfc[i])
					{
						ans++;
					}
				}
			}else{
				int td=min(rc[ptr].first.first,rcc[ptrc].first.first),tdc=min(rc[ptr].first.second,rcc[ptrc].first.second);
				ans+=td;
				ans+=tdc;
				rc[ptr].first.first-=td,rcc[ptrc].first.first-=td;
				rc[ptr].first.second-=tdc,rcc[ptrc].first.second-=tdc;
			}
			if(tt>ttc)
			{
				ptrc++;
				ttc=qjc[ptrc].second;
			}else{
				if(tt==ttc)
				{
					ptrc++,ptr++;
					tt=qj[ptr].second;
					ttc=qjc[ptrc].second;
				}else{
					ptr++;
					tt=qj[ptr].second;
				}
			}
		}
		printf("%d\n",ans);
	}
	return 0;
}
/*
WA:
#13 #19

1
10 
0001001001
0111011100
1111101111
1101111111
1+1
2,1 3,4
60pts

274 726
180 820
*/
