// I love Furina forever
# include <bits/stdc++.h>
# define maxn 100100
# define mod 1000000007
# define mem(a, val) memset(a, val, sizeof(a))
# define rep(i, j, k) for(int i = j; i <= k; ++i)
# define per(i, j, k) for(int i = j; i >= k; --i)
using namespace std;

int T, n, ans;
string s1, s2, t1, t2;
int num1[maxn], num2[maxn];
int cnt10[maxn], cnt11[maxn], cnt20[maxn], cnt21[maxn];

signed main() {
	freopen("edit.in", "r", stdin);
	freopen("edit.out", "w", stdout);
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> T;
	while(T--) {
		mem(cnt10, 0); mem(cnt11, 0); mem(cnt20, 0); mem(cnt21, 0); ans = 0;
		cin >> n >> s1 >> s2 >> t1 >> t2; s1 = ' ' + s1, s2 = ' ' + s2, t1 = ' ' + t1, t2 = ' ' + t2;
		int cnt0 = 1, cnt1 = 1;
		rep(i, 1, n) {
			if(t1[i] == '0') num1[i] = cnt0++;
			else {num1[i] = cnt0; if(i < n && t1[i + 1] == '0') cnt0++;}
			if(t2[i] == '0') num2[i] = cnt1++;
			else {num2[i] = cnt1; if(i < n && t2[i + 1] == '0') cnt1++;}
		}
		rep(i, 1, n) {
			if(s1[i] == '0') cnt10[num1[i]]++;
			else cnt11[num1[i]]++;
			if(s2[i] == '0') cnt20[num2[i]]++;
			else cnt21[num2[i]]++;
		}
		rep(i, 1, n) {
			int id1 = num1[i], id2 = num2[i];
			if(cnt10[id1] && cnt20[id2]) ans++, cnt10[id1]--, cnt20[id2]--;
			else if(cnt11[id1] && cnt21[id2]) ans++, cnt11[id1]--, cnt21[id2]--;
			else if(cnt10[id1] && cnt21[id2]) cnt10[id1]--, cnt21[id2]--;
			else cnt11[id1]--, cnt20[id2]--;
		}
		cout << ans << '\n';
	}
	return 0;
}

