#include <cstdio>

namespace Main {

using namespace std;

typedef long long LL;

LL read() {
	LL res, f = 1, c;
	for (c = getchar(); (c < '0' || c > '9') && c != '-';)
		c = getchar();
	if (c == '-') {
		f = -1;
		c = getchar();
	}
	for (res = 0; '0' <= c && c <= '9'; c = getchar())
		res = res * 10 + (c & 15);
	return res * f;
}

constexpr bool T = 1;
constexpr int N = 100005;

char a[N], b[N], a1[N], b1[N];


void solve() {
	int n = read(), ca[2] = {0, 0}, cb[2] = {0, 0}, ans = 0;
	scanf("%s %s %s %s", a + 1, b + 1, a1 + 1, b1 + 1);
	auto add = [&](int x, char *a, char *a1, int *c) {
		for (int i = x; i <= n && a1[i] & 1; ++i)
			++c[a[i] & 1];
		return;
	};
	add(1, a, a1, ca);
	add(1, b, b1, cb);
	for (int i = 1; i <= n; ++i) {
		int t = 0, ta = 0, tb = 0;
		if (a1[i] & 1 && b1[i] & 1) {
			if (ca[0] && cb[0]) {
				ta = tb = 0;
				++ans;
			} else if (ca[1] && cb[1]) {
				ta = tb = 1;
				++ans;
			} else {
				ta = (bool)ca[1];
				tb = (bool)cb[1];
			}
			--ca[ta];
			--cb[tb];
			continue;
		}
		if (!(a1[i] & 1)) {
			t = ta = a[i] & 1;
			add(i + 1, a, a1, ca);
		}
		if (!(b1[i] & 1)) {
			t = tb = b[i] & 1;
			add(i + 1, b, b1, cb);
		}
		if (a1[i] & 1)
			--ca[ta = ca[t] ? t : !t];
		if (b1[i] & 1)
			--cb[tb = cb[t] ? t : !t];
		ans += ta == tb;
	}
	printf("%d\n", ans);
	return;
}

void main() {
	freopen("edit.in", "r", stdin);
	freopen("edit.out", "w", stdout);
	for (int t = T ? read() : 1; t; --t)
		solve();
	return;
}
}

int main() {
	Main::main();
	return 0;
}

