#include <bits/stdc++.h>
#define IL inline
#define LL long long
#define eb emplace_back
#define sz(v) ((int) (v).size())
#define me(f, x) memset(f, x, sizeof(f))
#define mc(f, g) memcpy(f, g, sizeof(f))
#define L(i, j, k) for (int i = (j); i <= (k); ++i)
#define R(i, j, k) for (int i = (j); i >= (k); --i)
#define FIO(FILE) freopen(FILE".in", "r", stdin), freopen(FILE".out", "w", stdout)
using namespace std;

using vi = vector<int>;

constexpr int N = 1e5 + 9;
int n, c[2][N][2], to[2][N];
char s[2][N], t[2][N];

void slv () {
  cin >> n;
  L (o, 0, 1) {
    L (i, 1, n) {
      me(c[o][i], 0);
    }
  }
  L (i, 0, 1) {
    cin >> (s[i] + 1);
  }
  L (i, 0, 1) {
    cin >> (t[i] + 1);
  }
  L (o, 0, 1) {
    for (int i = 1, j; i <= n; i = j) {
      if (t[o][i] == '0') {
        to[o][i] = i;
        c[o][i][s[o][i] - '0'] += 1;
        j = i + 1;
        continue;
      }
      j = i;
      while (j <= n && t[o][j] == '1') {
        ++j;
      }
      L (k, i, j - 1) {
        to[o][k] = i;
        c[o][i][s[o][k] - '0'] += 1;
      }
    }
  }
  int ans = 0;
  L (i, 1, n) {
    int x = 1;
    L (o, 0, 1) {
      int d = min({c[0][to[0][i]][o], c[1][to[1][i]][o], x});
      ans += d;
      c[0][to[0][i]][o] -= d;
      c[1][to[1][i]][o] -= d;
      x -= d;
    }
  }
  cout << ans << '\n';
}

int main () {
  FIO("edit");
  ios::sync_with_stdio(0), cin.tie(0);
  int T;
  cin >> T;
  while (T--) {
    slv();
  }
}
// I love WHQ!