#include<bits/stdc++.h>
using namespace std;

const int maxn = 100005;
int T,n,ans;
char st,bt;
int s1[maxn],s2[maxn];
bool t1[maxn],t2[maxn];


void Af(){
	ans = 0;
	int x = s1[1];
	for(int i=1;i<=n;i++){
		if(x == s2[i])	ans++;
	}
	printf("%d\n",ans);
	return;
}

void Bf(){
	ans = 0;
	int ms1o=0,ms2o=0,ms1z=0,ms2z=0;
	int l,r,k;
	k=1;
	while(k<=n){
		l=k;
		while(k<=n && t1[k]!=0)	k++;
		r=k;
		if(r >= l){
			for(int i=l;i<r;i++){
				if(s1[i] == 1){
					ms1o++;
				}
				else ms1z++;
				
				if(s2[i] == 1){
					ms2o++;
				}
				else ms2z++;
			}
			ans += min(ms1o,ms2o);
			ans += min(ms1z,ms2z);
			ms1o=0;ms2o=0;ms1z=0;ms2z=0;
		}
		
		
		while(k<=n && t1[k]!=1){
			if(s1[k] == s2[k])	ans++;
			k++;
		}
		
	}
	printf("%d\n",ans);
	return;
}


int main(){
	freopen("edit.in","r",stdin);
	freopen("edit.out","w",stdout);
	scanf("%d",&T);
	for(int k=0;k<T;k++){
		scanf("%d",&n);
		
		bool ifA = 1;
		for(int i=0;i<=n;i++){
			scanf("%c",&st);
			if(st == '\n')	continue;
			s1[i] = st-'0';
			
			if(i>1){
				if(s1[i] != s1[i-1])	ifA=0;
			}
		}
		for(int i=0;i<=n;i++){
			scanf("%c",&st);
			if(st == '\n')	continue;
			s2[i] = st-'0';
		}
		//字符串赋值
		
		for(int i=0;i<=n;i++){
			scanf("%c",&bt);
			if(bt == '\n')	continue;
			t1[i] = bt-'0';
		}
		bool ifB = 1;
		for(int i=0;i<=n;i++){
			scanf("%c",&bt);
			if(bt == '\n')	continue;
			t2[i] = bt-'0';
			
			if(t1[i] != t2[i])	ifB=0;
		}
		//布尔赋值 
		
		//特殊条件判断
		if(ifA){
			Af();
			continue;
		}
		if(ifB){
			Bf();
			continue;
		}
		
		
		cout<<0<<endl;
	}
	

	return 0;
} 
