#include<bits/stdc++.h>
#define psb push_back
#define fi first
#define se second
#define endl '\n'
using namespace std;
const int N=1e5+5;
int t,n,s1[N],s2[N],t1[N],t2[N];
char ch;
void input(int a[]){
	for(int i=1;i<=n;i++){
		cin>>ch;
		a[i]=ch-'0';
	}
}
void get(int s[],int t[],int c[],int i){
	c[s[i]]++;
	if(!t[i])return;
	for(i++;i<=n&&t[i];i++)c[s[i]]++;
}
signed main(){
	freopen("edit.in","r",stdin);
	freopen("edit.out","w",stdout);
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	cin>>t;
	while(t--){
		cin>>n;
		input(s1),input(s2);
		input(t1),input(t2);
		int c1[2]={0},c2[2]={0},ans=0;
		for(int i=1;i<=n;i++){
			if(i==1||!t1[i-1]||!t1[i])get(s1,t1,c1,i);
			if(i==1||!t2[i-1]||!t2[i])get(s2,t2,c2,i);
			if(c1[0]&&c2[0]){
				c1[0]--,c2[0]--;
				ans++;
			}else if(c1[1]&&c2[1]){
				c1[1]--,c2[1]--;
				ans++;
			}else{
				if(c1[0])c1[0]--;
				else c1[1]--;
				if(c2[0])c2[0]--;
				else c2[1]--;
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}/*
1
6
011101
111010
111010
101101

*/
