#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 200;
template <class Ruby_Rose>
inline void read(Ruby_Rose &x) {
  x = 0;
  char ch = getchar(), w = 0;
  while (!isdigit(ch)) w = (ch == '-'), ch = getchar();
  while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
  x = w ? -x : x;
}
int T, n;
char s[2][N];
int main() {
  read(T);
  while (T--) {
    read(n);
    scanf("%s%s", s[0] + 1, s[1] + 1);
    int las = -1, ans = 0;
    for (register int i = 1; i <= n; i++) {
      int t = s[0][i] - '0' + s[1][i] - '0';
      if (t == 0) {
        if (las == -1)
          las = 0;
        else if (las == 0)
          ans++;
        else if (las == 1)
          las = -1, ans += 2;
      } else if (t == 1) {
        if (las == 0) ans++;
        ans += 2;
        las = -1;
      } else if (t == 2) {
        if (las == -1)
          las = 1;
        else if (las == 0)
          las = -1, ans += 2;
      }
    }
    printf("%d\n", ans + (las == 0));
  }
  return 0;
}
