#include <bits/stdc++.h>
#define fre(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout)
using namespace std;
const int N = 1e5+5;
char s1[N],s2[N],t1[N],t2[N];
int T,n;
int main()
{
	fre(edit);
	scanf("%d",&T);
	while(T--)
	{
		scanf("%d",&n);
		scanf("%s%s%s%s",s1+1,s2+1,t1+1,t2+1);
		int now1=0,now2=0,q0=0,q1=0,h0=0,h1=0;
		int ans=0;
		for(int i = 1;i <= n;i++)
		{
			now1 = max(now1,i);
			now2 = max(now2,i);
			while(t1[now1] == '1')
			{
				if(s1[now1] == '1') q1++;
				else q0++;
				now1++;
			}
			while(t2[now2] == '1')
			{
				if(s2[now2] == '1') h1++;
				else h0++;
				now2++;
			}
			if(now1 == i)
			{
				if(s1[now1] == '1') q1++;
				else q0++;
			}
			if(now2 == i)
			{
				if(s2[now2] == '1') h1++;
				else h0++;
			}
			if(q1 and h1) q1--,h1--,ans++;
			else if(q0 and h0) q0--,h0--,ans++;
			else{
				if(q1 and h0) q1--,h0--;
				else if(q0 and h1) q0--,h1--;
				else assert(0);
			}
		}
		printf("%d\n",ans);
	}
	return 0;
}
