#include <bits/stdc++.h>
using namespace std;

const int N = 1e5 + 10;

int t, n;
string a, b, c, d;
int cnt;
int sa[N], sub[N];

void work(int x, int i, int j)
{
	if (x)
	{
		while (a[i] == a[j] && sa[j] == 1 && j < n - 1) j++;
		if (a[j] == b[i] && sa[j] == 1)
		{
			swap(a[i], a[j]);
			cnt++;
		}
	}
	else
	{
		while (b[i] == b[j] && sub[j] == 1 && j < n - 1) j++;
		if (b[j] == a[i] && sub[j] == 1)
		{
			swap(b[i], b[j]);
			cnt++;
		}
	}
}

int main()
{
	freopen("edit.in", "r", stdin);
	freopen("edit.out", "w", stdout);
	cin >> t;
	while (t--)
	{
		cin >> n;
		cin >> a >> b >> c >> d;
		cnt = 0;
		memset(sa, 0, sizeof sa);
		memset(sub, 0, sizeof sub); 
		for (int i = 0; i < n; i++)
		{
			sa[i] = c[i] - '0';
			sub[i] = d[i] - '0';
		}

		for (int i = 0; i < n; i++)
		{			
			if (a[i] != b[i])
			{
				if (sa[i] == 0 && sub[i] == 0) continue;
				else if (sa[i] == 0)
					work(0, i, i);			
				else if (sub[i] == 0)
					work(1, i, i);
				else
				{
					work(1, i, i);
					
					if (a[i] != b[i]) work(0, i, i);
				}
			}
			else cnt++;
		}		
		cout << cnt << endl;
	}
	
	return 0;
} 
