#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
char s1[N], s2[N], t1[N], t2[N];
int cnt1[2], cnt2[2];
int n;
inline void sol() {
	cin >> n >> s1 + 1 >> s2 + 1 >> t1 + 1 >> t2 + 1;
	int ans = 0;
	for (int i = 1; i <= n; i++)
		s1[i] &= 1;
	for (int i = 1; i <= n; i++)
		s2[i] &= 1;
	for (int i = 1; i <= n; i++)
		t1[i] &= 1;
	for (int i = 1; i <= n; i++)
		t2[i] &= 1;
	int l1 = 1, l2 = 1;
#define add1() cnt1[s1[l1++]]++
#define add2() cnt2[s2[l2++]]++
	while (l1 <= n && l2 <= n) {
		if (l1 < l2)
			while (t1[l1])
				add1();
		else if (l1 > l2)
			while (t2[l2])
				add2();
		else {
			while (t1[l1])
				add1();
			while (t2[l2])
				add2();
		}
		if (l1 > n)
			while (l2 <= n)
				add2();
		if (l2 > n)
			while (l1 <= n)
				add1();
		if (l1 < l2) {
			add1();
			int tmp[2] = {min(cnt1[0], cnt2[0]), min(cnt1[1], cnt2[1])};
			ans += tmp[0] + tmp[1];
			memset(cnt1, 0, sizeof cnt1);
			cnt2[0] -= tmp[0];
			cnt2[1] -= tmp[1];
			cnt2[0] = min(cnt2[0], l2 - l1);
			cnt2[1] = min(cnt2[1], l2 - l1);
		} else if (l1 > l2) {
			add2();
			int tmp[2] = {min(cnt1[0], cnt2[0]), min(cnt1[1], cnt2[1])};
			ans += tmp[0] + tmp[1];
			memset(cnt2, 0, sizeof cnt2);
			cnt1[0] -= tmp[0];
			cnt1[1] -= tmp[1];
			cnt1[0] = min(cnt1[0], l1 - l2);
			cnt1[1] = min(cnt1[1], l1 - l2);
		} else {
			ans += min(cnt1[0], cnt2[0]) + min(cnt1[1], cnt2[1]);
			if (s1[l1++] == s2[l2++] && l1 <= n && l2 <= n)
				ans++;
			memset(cnt1, 0, sizeof cnt1);
			memset(cnt2, 0, sizeof cnt2);
		}
	}
#undef add1
#undef add2
	cout << ans << '\n';
}
int main() {
	freopen("edit.in", "r", stdin);
	freopen("edit.out", "w", stdout);
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int T;
	cin >> T;
	while (T--)
		sol();
}