#include<bits/stdc++.h>
using namespace std;
const int N=100005;
int t,n,s1[N],s2[N],t1[N],t2[N],ans=0,vis[N];
int main(){
	freopen("edit.in","r",stdin); 
	freopen("edit.out","w",stdout);
	cin>>t;
	while(t--){
		memset(vis,0,sizeof(vis));
		ans=0;
		cin>>n;
		for(int i=1;i<=n;i++){
			char data;
			cin>>data;
			s1[i]=int(data)-48;
		}
		for(int i=1;i<=n;i++){
			char data;
			cin>>data;
			s2[i]=int(data)-48;
		}
		for(int i=1;i<=n;i++){
			char data;
			cin>>data;
			t1[i]=int(data)-48;
		}
		for(int i=1;i<=n;i++){
			char data;
			cin>>data;
			t2[i]=int(data)-48;
		}
		for(int i=1;i<=n;i++){
			if(vis[i])continue;
			if(s1[i]==s2[i]){
				vis[i]=1;
				ans++;
				continue;
			}
			for(int j=i+1;j<=n;j++){
				if(t1[j]==0)break;
				if(s1[i]!=s1[j]){
					swap(s1[i],s1[j]);
					ans++;
					if(s1[j]==s2[j])vis[j]=1;
					break;
				}
			}
			if(s1[i]!=s2[i]){
				for(int j=i+1;j<=n;j++){
					if(t2[j]==0)break;
					if(s2[i]!=s2[j]){
						swap(s2[i],s2[j]);
						ans++;
						if(s1[j]==s2[j])vis[j]=1;
						break;
					}
				}
			}
		}
		printf("%d\n",ans);
	}
	return 0;
}
