#include <bits/stdc++.h>
using namespace std;
inline int min(int a, int b) { return a < b ? a : b; }
inline int max(int a, int b) { return a > b ? a : b; }
int main() {
  int t;
  cin >> t;
  for (int o = 0; o < t; ++o) {
    int n;
    string s;
    cin >> n >> s;
    bool a[n];
    for (int i = 0; i < n; ++i) a[i] = s[i] == '1';
    int l[n], r[n];
    l[0] = 0, r[n - 1] = 0;
    for (int i = 1; i < n; ++i)
      l[i] = l[i - 1] + a[i - 1], r[n - i - 1] = r[n - i] + a[n - i];
    if (!count(a, a + n, true)) {
      cout << n << '\n';
      continue;
    }
    int first = n, last = -1;
    for (int i = 0; i < n; ++i)
      if (a[i]) first = min(first, i), last = max(last, i);
    int ans = n + count(a, a + n, true);
    for (int i = first; i < n; ++i)
      ans = max(ans, 2 * (i - first + 1) + n - 1 - i + r[i]);
    for (int i = 0; i <= last; ++i)
      ans = max(ans, 2 * (last - i + 1) + i + l[i]);
    cout << ans << '\n';
  }
  return 0;
}
