#include <iostream>
using namespace std;
const int N = 1e5 + 10;
bool s1[N], s2[N], vis1[N], vis2[N];
int ans;
int n;
int main () {
	freopen("edit.in", "r", stdin);
	freopen("edit.out", "w", stdout);
	ios::sync_with_stdio(false);
	cin.tie(nullptr), cout.tie(nullptr);
	int T;
	cin >> T;
	while (T --) {
		bool A = 1, B = 1;
		int C1, C2;
		C1 = C2 = 0;
		cin >> n;
		string str1, str2, str3, str4;
		cin >> str1 >> str2 >> str3 >> str4;
		for (int i = 1; i <= n; i ++)
			s1[i] = str1[i - 1] - '0';
		for (int i = 1; i <= n; i ++)
			s2[i] = str2[i - 1] - '0';
		for (int i = 1; i <= n; i ++)
			vis1[i] = str3[i - 1] - '0';
		for (int i = 1; i <= n; i ++)
			vis2[i] = str4[i - 1] - '0';
		for (int i = 1; i <= n; i ++)
			if (i > 1 && s1[i] != s1[i - 1]) A = 0;
		for (int i = 1; i <= n; i ++)
			if (!vis1[i])
				C1 ++;
		for (int i = 1; i <= n; i ++) {
			if (vis1[i] != vis2[i]) B = 0;
			if (!vis2[i])
				C2 ++;
		}
		if (A) {
			bool als1 = s1[1];
			int cnta = 0;
			for (int i = 1; i <= n; i ++)
				if (als1 == s2[i]) cnta ++;
			cout << cnta << '\n';
			continue;
		}
		if (B) {
			pair <int, int> s1E, s2E;
			s1E.first = s1E.second = s2E.first = s2E.second = 0;
			int cntb = 0;
			for (int i = 1; i <= n; i ++) {
				if (i == n) {
					if (s1[i])
						s1E.second ++;
					else
						s1E.first ++;
					if (s2[i])
						s2E.second ++;
					else
						s2E.first ++;
				}
				if (!vis1[i] || i == n) {
					if (i != n && s1[i] == s2[i])
						cntb ++;
					cntb += min(s1E.first, s2E.first) + min(s1E.second, s2E.second);
					s1E.first = s1E.second = s2E.first = s2E.second = 0;
				} else {
					if (s1[i])
						s1E.second ++;
					else
						s1E.first ++;
					if (s2[i])
						s2E.second ++;
					else
						s2E.first ++;
				}
			}
			cout << cntb << '\n';
			continue;
		}
		if (C1 == 1 && C1 == C2) {
			int Lt1 = -1, Lt2 = -1;
			for (int i = 1; i <= n; i ++) {
				if (!vis1[i])
					Lt1 = i;
				if (!vis2[i])
					Lt2 = i;
				if (Lt1 != -1 && Lt2 != -1)
					break;
			}
			int cntc = 0;
			int miLT = min(Lt1, Lt2), mxLT = max(Lt1, Lt2);
			pair <int, int> Tots1, Tots2;
			for (int i = 1; i <= miLT; i ++) {
				if (s1[i])
					Tots1.second ++;
				else
					Tots1.first ++;
				if (s2[i])
					Tots2.second ++;
				else
					Tots2.first ++;
			}
			cntc += min(Tots1.first, Tots2.first) + min(Tots1.second, Tots2.second);
			Tots1.first = Tots1.second = Tots2.first = Tots2.second = 0;
			for (int i = miLT + 1; i <= mxLT; i ++) {
				if (s1[i])
					Tots1.second ++;
				else
					Tots1.first ++;
				if (s2[i])
					Tots2.second ++;
				else
					Tots2.first ++;
			}
			cntc += min(Tots1.first, Tots2.first) + min(Tots1.second, Tots2.second);
			Tots1.first = Tots1.second = Tots2.first = Tots2.second = 0;
			for (int i = mxLT + 1; i <= n; i ++) {
				if (s1[i])
					Tots1.second ++;
				else
					Tots1.first ++;
				if (s2[i])
					Tots2.second ++;
				else
					Tots2.first ++;
			}
			cntc += min(Tots1.first, Tots2.first) + min(Tots1.second, Tots2.second);
			Tots1.first = Tots1.second = Tots2.first = Tots2.second = 0;
			cout << cntc << '\n';
			continue;
		}
		pair <int, int> E1, E2;
		for (int i = 1; i <= n; i ++) {
			if (s1[i])
				E1.second ++;
			else
				E1.first ++;
			if (s2[i])
				E2.second ++;
			else
				E2.first ++;
		}
		cout << min(E1.first, E2.first) + min(E1.second, E2.second) << '\n';
		continue;
	}
	return 0;
}
