#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<queue>
#include<ctime>
#include<cmath>
#include<set>
#include<map>
#define infile(filename) freopen(filename".in","r",stdin)
#define outfile(filename) freopen(filename".out","w",stdout)
#define usefile(filename) infile(filename),outfile(filename)
using namespace std;
char gc() { static const int BUF=1<<20; static char ch[BUF],*l=ch,*r=ch; return (l==r&&(r=(l=ch)+fread(ch,1,BUF,stdin),l==r))?EOF:*l++; }
template <typename T> void read(T &a) { static char ch,fushu; fushu=a=0; do ch=gc(); while(ch!='-'&&(ch<48||ch>57)); if(ch=='-') fushu=1,ch=gc(); do a=(a<<1)+(a<<3)+(ch^48),ch=gc(); while(ch>47&&ch<58); if(fushu) a=-a; return ; }
template <typename T,typename ...Args> void read(T &a,Args &...args) { read(a),read(args...); }
const int N=100099;
int T,n,s1[N]={},s2[N]={},t1[N]={},t2[N]={},pre1[N][2]={},pre2[N][2]={},ans1[N]={},ans2[N]={};
int main()
{
	usefile("edit");
	int i; char ch;
	int cnt1[2]={},cnt2[2]={},ans;
	read(T);
	loop : --T;
	read(n);
	do ch=gc(); while(ch!='0'&&ch!='1');
	for(i=1;i<=n;++i) s1[i]=ch=='1',ch=gc();
	do ch=gc(); while(ch!='0'&&ch!='1');
	for(i=1;i<=n;++i) s2[i]=ch=='1',ch=gc();
	do ch=gc(); while(ch!='0'&&ch!='1');
	for(i=1;i<=n;++i) t1[i]=ch=='1',ch=gc();
	do ch=gc(); while(ch!='0'&&ch!='1');
	for(i=1;i<=n;++i) t2[i]=ch=='1',ch=gc();
	for(i=n;i;--i) pre1[i][0]=s1[i]==0,pre1[i][1]=s1[i]==1;
	for(i=n-1;i;--i) if(t1[i]&&t1[i+1]) {
		pre1[i][0]+=pre1[i+1][0],pre1[i+1][0]=0;
		pre1[i][1]+=pre1[i+1][1],pre1[i+1][1]=0;
	}
	for(i=n;i;--i) pre2[i][0]=s2[i]==0,pre2[i][1]=s2[i]==1;
	for(i=n-1;i;--i) if(t2[i]&&t2[i+1]) {
		pre2[i][0]+=pre2[i+1][0],pre2[i+1][0]=0;
		pre2[i][1]+=pre2[i+1][1],pre2[i+1][1]=0;
	}
	cnt1[0]=cnt1[1]=cnt2[0]=cnt2[1]=0;
	for(i=1,ans=0;i<=n;++i) {
		cnt1[0]+=pre1[i][0];
		cnt1[1]+=pre1[i][1];
		cnt2[0]+=pre2[i][0];
		cnt2[1]+=pre2[i][1];
		if(cnt1[0]&&cnt2[0]) ans1[i]=0,ans2[i]=0;
		else if(cnt1[1]&&cnt2[1]) ans1[i]=1,ans2[i]=1;
		else ans1[i]=cnt1[1]>0,ans2[i]=cnt2[1]>0;
		ans+=ans1[i]==ans2[i];
		--cnt1[ans1[i]],--cnt2[ans2[i]];
	}
	printf("%d\n",ans);
	if(T) goto loop;
}
