#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
int t,n,s1[maxn],s2[maxn],num[2][2][maxn];
int opt1[maxn],opt2[maxn];
int pre1[maxn],pre2[maxn],k1[maxn][2],k2[maxn][2];
int dp[maxn];
struct node
{
	int k,id;
} a[maxn];
int main()
{
	freopen("edit.in","r",stdin);
	freopen("edit.out","w",stdout);
	scanf("%d",&t);
	while (t--)
	{
		scanf("%d",&n);
		for (int i = 1;i <= n;i++)
			scanf("%1d",&s1[i]),pre1[i] = pre1[i - 1] + s1[i];
		for (int i = 1;i <= n;i++)	
			scanf("%1d",&s2[i]),pre2[i] = pre2[i - 1] + s2[i];
		for (int i = 1;i <= n;i++)
			scanf("%1d",&opt1[i]);
		for (int i = 1;i <= n;i++)
			scanf("%1d",&opt2[i]);
		if (pre1[n] == n)
		{
			cout << min(n,pre2[n]) << endl;
			continue;
		}
		bool flag = 0;
		int cnt11 = 0,cnt22 = 0;
		for (int i = 1;i <= n;i++)
		{
			if (opt1[i] != opt2[i])
				flag = 1;
			if (!opt1[i])cnt11++;
			if (!opt2[i])cnt22++;
		}
		if (!flag)
		{
			int ans = 0,kkk1 = 0,kkk2 = 0,kkk3 = 0,kkk4 = 0;
			for (int i = 1;i <= n;i++)
			{
				if (!opt1[i])
				{
					ans += (min(kkk1,kkk3) + min(kkk2,kkk4)),ans += (s1[i] == s2[i]);
					kkk1 = kkk2 = kkk3 = kkk4 = 0;
				}
				else
					kkk1 += (s1[i] == 1),kkk2 += (s1[i] == 0),kkk3 += (s2[i] == 1),kkk4 += (s2[i] == 0); 
			}
			cout << ans << endl;
		}
		else
		{
			if (cnt11 == 1 and cnt22 == 1)
				cout << min(pre1[n],pre2[n]) + min(n - pre1[n],n - pre2[n]); 
			else
				cout << min(pre1[n],pre2[n]) + min(n - pre1[n],n - pre2[n]);
		}
	}
	return 0;
}
