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

inline int read(){
	int ans=0,f=1;char c=getchar();
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c)){ans=ans*10+c-48;c=getchar();}
	return ans*f;
}

inline void print(int x){
	if(x<0){putchar('-');x=-x;}
	if(x<10){putchar(x+48);return;}
	print(x/10);putchar(x%10+48);
	return;
}

const int N=1e5+10;
int T, n, ans, a[N], a1[N], b[N], b1[N];

void get(int *a){
	int i=0;
	char c=getchar();
	while(!isdigit(c)) c=getchar();
	while(isdigit(c)){
		a[++i]=c-48;
		c=getchar();
	}
	return;
}

bool ifA(){
	for(int i=2; i<=n; i++)
		if(a[i]!=a[i-1]) return false;
	
	return true;
}

bool ifB(){
	for(int i=1; i<=n; i++)
		if(a1[i]!=b1[i]) return false;
	
	return true;
}
/*
string s1[1030], s2[1030];
int cnt1, cnt2;
map <string, bool> mp1, mp2;

void dfs1(string s, int cnt){
	if(cnt>3000) return;
	for(int i=2; i<=n; i++)
		if(s[i]!=s[i-1] && a1[i] && a1[i-1]){
			swap(s[i], s[i-1]);
			if(mp1[s]){
				swap(s[i], s[i-1]);continue;
			}
			
			s1[++cnt1]=s;
			mp1[s]=true;
			dfs1(s, cnt+1);
			swap(s[i], s[i-1]);
		}
	
	return;
}

void dfs2(string s, int cnt){
	if(cnt>3000) return;
	for(int i=2; i<=n; i++)
		if(s[i]!=s[i-1] && b1[i] && b1[i-1]){
			swap(s[i], s[i-1]);
			if(mp2[s]){
				swap(s[i], s[i-1]);continue;
			}
			
			s2[++cnt2]=s;
			mp2[s]=true;
			dfs2(s, cnt+1);
			swap(s[i], s[i-1]);
		}
	
	return;
}
*/
int main(){
	freopen("edit.in", "r", stdin);
	freopen("edit.out", "w", stdout);
	
	T=read();
	while(T--){
		n=read();
		memset(a, 0, sizeof(a));
		memset(b, 0, sizeof(b));
		memset(a1, 0, sizeof(a1));
		memset(b1, 0, sizeof(b1));
		
		get(a);get(b);get(a1);get(b1);
		
		if(ifA()){
			int cnt=0;
			for(int i=1; i<=n; i++)
				if(a[i]==b[i]) cnt++;
			
			print(cnt); putchar('\n');
			continue;
		}
		
		if(ifB()){
			int cnt_a[2], cnt_b[2];
			cnt_a[0]=0, cnt_a[1]=0, cnt_b[0]=0, cnt_b[1]=0;
			int cnt=0;
			for(int i=1; i<=n+1; i++){
				if(a1[i])
					cnt_a[a[i]]++, cnt_b[b[i]]++;
				
				else {
					cnt+=min(cnt_a[0], cnt_b[0])
						+min(cnt_a[1], cnt_b[1]);
					cnt_a[0]=0, cnt_a[1]=0, cnt_b[0]=0, cnt_b[1]=0;
					if(a[i]==b[i] && i!=n+1) cnt++;
				}
			}
			print(cnt); putchar('\n');
			continue;
		}
		/*
		if(n<=10){
			memset(mp1, 0, sizeof(mp1));
			memset(mp2, 0, sizeof(mp2));
			cnt1=1, cnt2=1;
			s1[1]=" ";s2[1]=" ";
			for(int i=1; i<=n; i++)
				s1[1]=s1[1]+(char)(a[i]+48);
			for(int i=1; i<=n; i++)
				s2[1]=s2[1]+(char)(b[i]+48);
			
			mp1[s1[1]]=true; mp2[s2[1]]=true;
			dfs1(s1[1], 1);
			dfs2(s2[1], 1);
		}*/
	}
	
	return 0;
}
