#include<iostream>
#include <cstdio>
#include<cstring>
using namespace std;
const int N = 100010;
int n, a[N], b[N], T;
bool s1[N], s2[N];
string x;

struct lines {
	int l, r, n0 = 0, n1 = 0;
}c[N], d[N];
int idxc, idxd;
int main() {
	freopen("edit.in", "r", stdin);
	freopen("edit.out", "w", stdout);
	
	cin >> T;
	while (T --) {
		idxc = idxd = 0;
		scanf("%d\n", &n);
		for (int i = 0; i <= n; ++ i) a[i] = b[i] = 0, s1[i] = s2[i] = false, c[i].l = c[i].r = d[i].l = d[i].r = c[i].n0 = d[i].n0 = c[i].n1 = d[i].n1 = 0;
		getline(cin, x);
		for (int i = 0; i < x.size(); ++ i) a[i] = x[i] - '0';
		getline(cin, x);
		for (int i = 0; i < x.size(); ++ i) b[i] = x[i] - '0';
		getline(cin, x);
		for (int i = 0; i < x.size(); ++ i) 
			if (x[i] == '1') s1[i] = true;
			else s1[i] = false;
		getline(cin, x);
		for (int i = 0; i < x.size(); ++ i)
			if (x[i] == '1') s2[i] = true;
			else s2[i] = false;
		
		for (int i = 1; i <= n;) {
			c[++ idxc].l = i;
			if (!s1[i - 1]) {
				c[idxc].r = i;
				if (a[i - 1] == 1) c[idxc].n1 = 1;
				else c[idxc].n0 = 1;
				i ++;
			}
			else {
				c[idxc].n1 = c[idxc].n0 = 0;
				int j = i;
				while (j <= n && s1[j - 1]) {
					if (a[j - 1] == 1) c[idxc].n1 ++;
					else c[idxc].n0 ++;
					j ++;
				}
				c[idxc].r = j - 1;
				i = j;
			}
		}
		for (int i = 1; i <= n;) {
			d[++ idxd].l = i;
			if (!s2[i - 1]) {
				d[idxd].r = i;
				if (b[i - 1] == 1) d[idxd].n1 = 1;
				else d[idxd].n0 = 1;
				i ++;
			}
			else {
				d[idxd].n0 = d[idxd].n1 = 0;
				int j = i;
				while (j <= n && s2[j - 1]) {
					if (b[j - 1] == 1) d[idxd].n1 ++;
					else d[idxd].n0 ++;
					j ++;
				}
				d[idxd].r = j - 1;
				i = j;
			}
		}
//		puts("Yes");
//		for (int i = 1; i <= idxc; ++ i) cout << c[i].l << ' ' << c[i].r << ' ' << c[i].n0 << ' ' << c[i].n1 << endl;
//		puts("Yes");
//		for (int i = 1; i <= idxd; ++ i) cout << d[i].l << ' ' << d[i].r << ' ' << d[i].n0 << ' ' << d[i].n1 << endl;
//		puts("Yes");
		int ans = 0;
		for (int i = 1, j = 1; i <= idxc; ++ i) {
			while (d[j].r < c[i].l) j ++;
			while (j <= idxd && d[j].l <= c[i].r) {
				int jr = min(min(d[j].r - c[i].l, d[j].r - d[j].l), min(c[i].r - d[j].l, c[i].r - c[i].l)) + 1;
				while (jr >= 1) {
					if (c[i].n0 == 0 && d[j].n1 == 0 || c[i].n1 == 0 && d[j].n0 == 0) break;
					else if (c[i].n1 > 0 && d[j].n1 > 0) c[i].n1 --, d[j].n1 --, ans ++, jr --;
					else if (c[i].n0 > 0 && d[j].n0 > 0) c[i].n0 --, d[j].n0 --, ans ++, jr --;
				}
				j ++;
			}
			j --;
		}
		cout << ans << endl;
	}
	return 0;
}
