/**
 *    author:  tourist
 *    created: 21.10.2026 10:10:03
**/
#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include "algo/debug.h"
#else
#define debug(...) 42
#endif

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int tt;
  cin >> tt;
  while (tt--) {
    int n;
    cin >> n;
    string sl, sr;
    cin >> sl >> sr;
    int i = 0;
    int ans = 1;
    while (i + 1 < n) {
      if (sr[i] == '1' && sl[i] == '1') {
        if (i + 2 < n) {
          i += 2;
          ans += 1;
        } else {
          break;
        }
      } else {
        i += 1;
        ans += 1;
      }
    }
    cout << ans << '\n';
  }
  return 0;
}
