#include <bits/stdc++.h>
using namespace std;
int t;string s1,s2,s3,s4;
int main()
{
	freopen("edit.in","r",stdin);
	freopen("edit.out","w",stdout);
	cin>>t;
	while(t--)
	{
		int n;
		cin>>n;
		cin>>s1;cin>>s2;cin>>s3;cin>>s4;
		s1 = ' '+s1;s2 = ' '+s2;s3 = ' '+s3;s4 = ' '+s4;
		bool flag = true;
		char k = s1[1];
		for(int i = 1;i<=n;i++)
		    if(s1[i]!=k)     flag = false;
		if(flag)
		{
			int tot = 0;char k = s1[1];
			for(int i = 1;i<=n;i++)
			    if(s2[i]==k)    tot++;
			printf("%d\n",tot);
		}
	}
	return 0;
}
