#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e5+10;
string s1,s2;
string t1,t2;
int a[2],b[2];
int l1,l2;
int n,T;
int main(){
	freopen("edit.in","r",stdin);
	freopen("edit.out","w",stdout);
	cin>>T;
	while(T--){
		a[0]=a[1]=b[0]=b[1]=0;
		cin>>n;
		cin>>s1>>s2>>t1>>t2;
		for(int i=0;i<n;i++){
			a[s1[i]-'0']++;
		}
		for(int i=0;i<n;i++){
			b[s2[i]-'0']++;
		}
		cout<<min(a[0],b[0])+min(a[1],b[1])<<endl; 
	} 
	return 0;
}

