#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
int T,n,a[N],b[N],ans;
char s[N],ss[N],t[N],tt[N];
signed main()
{
	freopen("edit.in","r",stdin);
	freopen("edit.out","w",stdout);
    cin>>T;
    while(T--)
    {
    	ans=0;
    	cin>>n;
    	for(int i=1;i<=n;i++) cin>>s[i],a[i]=s[i]-'0';
    	for(int i=1;i<=n;i++) cin>>ss[i],b[i]=ss[i]-'0';
    	for(int i=1;i<=n;i++) cin>>t[i];
    	for(int i=1;i<=n;i++) cin>>tt[i];
    	for(int i=1;i<=n;i++)
    	{
    		if(a[i]!=b[i])
    		{
    			if(t[i]=='1' && t[i+1]=='1' && a[i+1]==b[i])
    			{
    				swap(a[i],a[i+1]);
    				ans++;
				}
				else if(tt[i]=='1' && tt[i+1]=='1' && b[i+1]==a[i])
				{
					swap(b[i],b[i+1]);
					ans++;
				}
			}
			else if(a[i]==b[i]) ans++;
		}
		cout<<ans<<endl;
	}
	fclose(stdin);fclose(stdout);
	return 0;
} 
