#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  int test;
  cin >> test;
  while (test--) {
    int n;
    cin >> n;
    string s;
    cin >> s;
    int first = -1, last = -2;
    for (int i = 0; i < s.size(); i++)
      if (s[i] == '1') {
        first = i;
        break;
      }
    for (int i = s.size() - 1; i >= 0; i--)
      if (s[i] == '1') {
        last = i;
        break;
      }
    if (first == 0 || last == n - 1)
      cout << 2 * n << "\n";
    else if (first == last) {
      int tmp = max(n + 1, 2 * (first + 1));
      cout << max(tmp, 2 * (n - first)) << "\n";
    } else if (first == -1)
      cout << n << "\n";
    else {
      int tmp = max(first + 2 * (last - first + 1),
                    n - 1 - last + 2 * (last - first + 1));
      int x = first;
      for (int i = first; i <= last; i++) {
        x += (s[i] == '1') ? (2) : (1);
      }
      x += (n - 1 - last);
      int k = min(first, n - 1 - last);
      tmp = max(tmp, 2 * (n - k));
      cout << max(tmp, x) << "\n";
    }
  }
}
