#include<bits/stdc++.h>
#define ll long long
#define yes cout << "YES" << endl
#define no cout << "NO" << endl
#define testing cout << "testing ";
#define mod 1000000007
#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
void do_the_honour() {
int N;
string S;
cin >> N >> S;
int max_consecutive_ones = 0, current_consecutive = 0;
for (char c : S) {
if (c == '1') {
current_consecutive++;
max_consecutive_ones = max(max_consecutive_ones, current_consecutive);
} else {
current_consecutive = 0;
}
}
int zeros_count = count(S.begin(), S.end(), '0');
if (zeros_count == 0) {
cout << N << endl;
} else {
cout << max_consecutive_ones << endl;
}
}
int main() {
optimize();
int t = 1;
cin >> t;
for(int z = 1; z <= t; z++) {
do_the_honour();
}
return 0;
}