#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
const int INF = 0x3f3f3f3f;
int main(){
//	freopen(".in", "r", stdin);
//	freopen(".out", "w", stdout);
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	int T;
	cin >> T;
	while(T--){
		int n, ans = 0, cnt1 = 0, cnt2 = 0, tot01 = 0, tot02 = 0, tot11 = 0, tot12 = 0;
		cin >> n;
		string s1, s2, t1, t2;
		cin >> s1 >> s2 >> t1 >> t2;
		int pos[N][2], del1[N][2], del2[N][2];
		int pos01[N], pos02[N], pos11[N], pos12[N];
		for (int i = 0; i < n; i++){
			if (t1[i] == '0')
				pos[++cnt1][0] = i;
			if (t2[i] == '0')
				pos[++cnt2][1] = i;
			if (s1[i] == '0')
				pos01[++tot01] = i;
			else
				pos11[++tot11] = i;
			if (s2[i] == '0')
				pos02[++tot02] = i;
			else
				pos12[++tot12] = i;
 		}
 		tot01 = min(tot01, tot02);
		for (int i = 1; i <= tot01; i++){
			int pos1 = pos01[i], pos2 = pos02[i];
			if(t1[pos1] == '0' && t2[pos2] == '0'){
				if(pos1 == pos2) ans++;
				continue;
			}
			
		} 	
	}
	return 0;
}
