#include <bits/stdc++.h>
#define FileIO_(file) \
    freopen (file ".in", "r", stdin); \
    freopen (file ".out", "w", stdout);

using namespace std;

namespace Main {

namespace IO {

void read () {}

template<typename Tp, typename... Args>
void read (Tp &x, Args&... rest) {
    int c = getchar (); x = 0;
    while (!isdigit (c)) c = getchar ();
    do x = (x << 1) + (x << 3) + (c & 15);
    while (isdigit (c = getchar ()));
    read (rest...);
}

template<typename Tp>
void write (Tp x) {
    static int top, wr[50];
    do wr[++top] = x % 10; while (x /= 10);
    while (top) putchar (wr[top--] | 48);
}

} // namespace IO

using namespace IO;
using ll = long long;

const int maxn = 1e5 + 20;
int n, d, ans, p[2], cnt[2][2];
char s[2][maxn], t[2][maxn];

void solve () {
    scanf ("%d%s%s%s%s", &n, s[0] + 1, s[1] + 1, t[0] + 1, t[1] + 1);
    ans = 0; p[0] = p[1] = 1;
    memset (cnt, 0, sizeof (cnt));
    while (p[0] <= n || p[1] <= n) {
        if (p[0] < p[1]) {
            ++cnt[0][s[0][p[0]] & 1];
            if (t[0][p[0]++] != '0') {
                while (p[0] <= n && t[0][p[0]] != '0') {
                    ++cnt[0][s[0][p[0]++] & 1];
                }
            }
        } else {
            ++cnt[1][s[1][p[1]] & 1];
            if (t[1][p[1]++] != '0') {
                while (p[1] <= n && t[1][p[1]] != '0') {
                    ++cnt[1][s[1][p[1]++] & 1];
                }
            }
        }
        d = min (cnt[0][0], cnt[1][0]);
        cnt[0][0] -= d; cnt[1][0] -= d; ans += d;
        d = min (cnt[0][1], cnt[1][1]);
        cnt[0][1] -= d; cnt[1][1] -= d; ans += d;
        d = min (cnt[0][0], cnt[1][1]);
        cnt[0][0] -= d; cnt[1][1] -= d;
        d = min (cnt[0][1], cnt[1][0]);
        cnt[0][1] -= d; cnt[1][0] -= d;
    }
    printf ("%d\n", ans);
}

int main () {
    int t; read (t);
    while (t--) solve ();
    return 0;
}

} // namespace Main

int main () {
    FileIO_("edit");
    return Main::main ();
}