#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+10;
int n;
char s1[maxn],s2[maxn],t1[maxn],t2[maxn];
int main(){
	freopen("edit.in","r",stdin);
	freopen("edit.out","w",stdout);
	int T;scanf("%d",&T);
	while(T--){
		int ans=0;
		bool flag=true;
		scanf("%d",&n);
		cin>>s1[1];
		for(int i=2;i<=n;i++){
			cin>>s1[i];
			if(s1[i]!=s1[i-1]) flag=false;
		}
		for(int i=1;i<=n;i++) cin>>s2[i];
		for(int i=1;i<=n;i++) cin>>t1[i];
		for(int i=1;i<=n;i++) cin>>t2[i];
		if(flag){
			for(int i=1;i<=n;i++)
				if(s2[i]==s1[i]) ans++;
			printf("%d\n",ans);
			continue;
		}
	}
	return 0;
}
