#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma comment(linker, "/STACK:1024000000,1024000000")
using namespace std;
long long x, y, z, a, b, c, d;
string s;
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  ;
  cin >> x;
  while (x--) {
    cin >> y >> s;
    long long f = -1, e = -1;
    for (int i = 0; i < y; i++) {
      if (s[i] == '1' && f == -1) {
        f = i;
      }
      if (s[i] == '1') {
        e = i;
      }
    }
    if (e == -1 && f == -1) {
      cout << y << endl;
      continue;
    }
    long long st, n;
    if (f <= y - e - 1) {
      st = f;
      n = f;
      for (int i = st; i < y; i++) {
        if (s[i] == '1') {
          n += 2;
        } else {
          n++;
        }
      }
      n = max(n, 2 * (y - f));
    } else {
      st = e;
      n = y - e - 1;
      for (int i = st; i >= 0; i--) {
        if (s[i] == '1') {
          n += 2;
        } else {
          n++;
        }
      }
      n = max(n, 2 * (y - (y - e - 1)));
    }
    cout << n << endl;
  }
  return 0;
}
