#include<bits/stdc++.h>
using namespace std;
int in()
{
	int w=0,f=1;
	char c=getchar();
	while(!isdigit(c))
	{
		if(c=='-') f=-1;
		c=getchar();
	}
	while(isdigit(c))
	{
		w=w*10+c-'0';
		c=getchar();
	}
	return w*f;
}
void out(int w)
{
	if(w<0) 
	{
		putchar('-');
		out(-w);
		return;
	}
	if(w>=10) out(w/10);
	putchar(w%10+'0');
}
int T,n,ans;
string s1,s2,t1,t2;
int main()
{
	freopen("edit.in","r",stdin);
	freopen("edit.out","w",stdout);
	cin>>T;
	while(T--)
	{
		ans=0;
		n=in();
		getline(cin,s1);
		getline(cin,s2);
		getline(cin,t1);
		getline(cin,t2);
		for(int i=0;i<n;i++) if(s1[i]==s2[i]) ans++;
		out(ans);
		putchar('\n'); 
	} 
	return 0;
 } 
/*
011101
111010

*/
