#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
int T;
cin >> T;
while (T--) {
int N;
string S;
cin >> N >> S;
// Count the number of consecutive '1's blocks
vector<int> onesBlocks;
int count = 0;
for (int i = 0; i < N; ++i) {
if (S[i] == '1') {
count++;
} else {
if (count > 0) {
onesBlocks.push_back(count);
}
count = 0;
}
}
if (count > 0) {
onesBlocks.push_back(count); // If the string ends with 1's
}
// If no blocks of 1's are found, answer is 0
if (onesBlocks.empty()) {
cout << 0 << endl;
} else {
// The longest block of consecutive 1's will be the result
int maxConsecutiveOnes = *max_element(onesBlocks.begin(), onesBlocks.end());
cout << maxConsecutiveOnes << endl;
}
}
return 0;
}