#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
// Function to calculate maximum consecutive 1s
int maxConsecutiveOnes(string &s) {
int max_count = 0, count = 0;
for (char c : s) {
if (c == '1') {
count++;
max_count = max(max_count, count);
} else {
count = 0;
}
}
return max_count;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
string s;
cin >> s;
// Indices of '0's
vector<int> zero_indices;
for (int i = 0; i < n; ++i) {
if (s[i] == '0') {
zero_indices.push_back(i);
}
}
// Simulate the game
int left = 0, right = zero_indices.size() - 1;
bool roy_turn = true;
while (left <= right) {
if (roy_turn) {
s[zero_indices[left]] = '1';
left++;
} else {
s[zero_indices[right]] = '0';
right--;
}
roy_turn = !roy_turn;
}
cout << maxConsecutiveOnes(s) << endl;
}
return 0;
}