#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N=100001;
int n;
char a[N],b[N];
char vis1[N],vis2[N];
int main(){
	freopen("edit.in","r",stdin);
	freopen("edit.out","w",stdout);
	int T;cin>>T;
	while(T--){
		cin>>n;
		bool flag1=1;
		cin>>a+1>>b+1>>vis1+1>>vis2+1;
		for(int i=2;i<=n;i++){
			if(a[i]!=a[i-1])flag1=0;
		}
		if(flag1){
			int ans=0;
			for(int i=1;i<=n;i++){
				if(a[i]==b[i])ans++;
			}
			cout<<ans<<endl;
		}
	}
	return 0;
}
