#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
int m(int n, const string &s) {
vector<int> seg;
int c = 0;
for (int i = 0; i < n; ++i) {
if (s[i] == '1') {
c++;
while (i < n && s[i] == '1') {
i++;
}
seg.push_back(c);
c = 0;
}
}
if (seg.empty()) return 0;
if (seg.size() == 1) return seg[0];
return *max_element(seg.begin(), seg.end());
}
int main() {
int t;
cin >> t;
while (t--) {
int n;
string s;
cin >> n >> s;
cout << m(n, s) << endl;
}
return 0;
}