#include<bits/stdc++.h>
using namespace std;
int i,n,t,s;
void solve(){
	scanf("%d",&n);
	bitset<100000>s1,s2,t1,t2;
	cin>>s1>>s2>>t1>>t2;
	for(i=0;i<n;++i)if(s1[i]==s2[i])s++;
	printf("%d\n",s);}
int main(){
	freopen("edit.in","r",stdin);
	freopen("edit.out","w",stdout);
	scanf("%d",&t);
	while(t--)solve();
	return 0;}
