#include <bits/stdc++.h>
#define _rep(i_, a_, b_) for(int i_ = a_; i_ <= b_; ++i_)
int in(void) { int x; scanf("%d", &x); return x; } 
typedef long long ll;
using namespace std;
const int kN = 105000;
char s[kN], t[kN];
char S[kN], T[kN];
pair<int, int> cnt[kN * 2];
int belS[kN], belT[kN];
int main() {
	freopen("edit.in", "r", stdin);
	freopen("edit.out", "w", stdout);
	int TC = in();
	while(TC--) {
		int n = in();
		scanf("%s%s%s%s", s + 1, t + 1, S + 1, T + 1);
		int N = 0;
		for(int l = 1, r; l <= n; l = r + 1) {
			r = l; if(S[r] == '1') while(r < n && S[r + 1] == '1') ++r;
			cnt[++N] = make_pair(0, 0);
			_rep(i,l,r) {
				belS[i] = N;
				if(s[i] == '1') ++cnt[N].first;
				else ++cnt[N].second;
			}
//			debug("S: %d %d\n", l, r);
		}
		for(int l = 1, r; l <= n; l = r + 1) {
			r = l; if(T[r] == '1') while(r < n && T[r + 1] == '1') ++r;
			cnt[++N] = make_pair(0, 0);
			_rep(i,l,r) {
				belT[i] = N;
				if(t[i] == '1') ++cnt[N].first;
				else ++cnt[N].second;
			}
//			debug("T: %d %d\n", l, r);
		}
		int mat = 0;
		_rep(i,1,n) {
			if(cnt[belS[i]].first && cnt[belT[i]].first) ++mat, --cnt[belS[i]].first, --cnt[belT[i]].first;
			else if(cnt[belS[i]].second && cnt[belT[i]].second) ++mat, --cnt[belS[i]].second, --cnt[belT[i]].second;
			else {
				if(cnt[belS[i]].first) --cnt[belS[i]].first;
				if(cnt[belS[i]].second) --cnt[belS[i]].second;
				if(cnt[belT[i]].first) --cnt[belT[i]].first;
				if(cnt[belT[i]].second) --cnt[belT[i]].second;
			}
		}
		printf("%d\n", mat);
	}
	return 0;
} 
