#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5+5;
int T, n, idxa, idxb;
char sf[maxn], sc[maxn], tf[maxn], tc[maxn];
bool checka() {
	for (int i = 1; i < n; i++) if (sf[i]!=sf[i-1]) return false;
	return true;
}
void solvea() {
	int cnt=0;
	for (int i = 0; i < n; i++) if (sc[i]==sf[i]) cnt++;
	cout << cnt << endl;
}
bool checkb() {
	for (int i = 0; i < n; i++) if (tf[i]!=tc[i]) return false;
	return true;
}
void solveb(){
	int ans=0, cnta=0, cntb=0, cnt=0;
	for (int i = 0; i < n; i++) {
		if (tf[i]=='0') {
			ans+=(cnt-abs(cnta-cntb));
			cnta=0,cntb=0,cnt=0;
			if (sf[i]==sc[i]) ans++;
		} else {
			if (sf[i]=='1') cnta++;
			if (sc[i]=='1') cntb++;
			cnt++;
		}
	}
	ans+=(cnt-abs(cnta-cntb));
	cout << ans << endl;
}
bool checkc() {
	bool flagf=0, flagc=0;
	for (int i = 0; i < n; i++) {
		if (flagf&&tf[i]=='0') return false;
		if (tf[i]=='0') flagf=1;
		if (flagc&&tc[i]=='0') return false;
		if (tc[i]=='0') flagc=1;
	}
	return true;
}
void solve() {
	int myt=0, wyf=0;
	for (int i = 0; i < n; i++) {
		if (sf[i]=='1') myt++;
		if (sc[i]=='1') wyf++;
	}
	cout << n-abs(myt-wyf) << endl;
}
int main() {
	freopen("edit.in", "r", stdin);
	freopen("edit.out", "w", stdout);
	cin >> T;
	while (T--) {
		cin >> n;
		for (int i = 0; i < n; i++) cin >> sf[i];
		for (int i = 0; i < n; i++) cin >> sc[i];
		for (int i = 0; i < n; i++) cin >> tf[i];
		for (int i = 0; i < n; i++) cin >> tc[i];
		if (checka()) {
			solvea();
		} else if (checkb()) {
			solveb();
		} else {
			solve();
		}
	}
	return 0;
} 
