#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define ll long long
#define INF LLONG_MIN
int fukc(string &s) {
int n = s.size();
int mxo = 0, co = 0;
vector<int> v;
for (int i = 0; i < n; i++) {
if (s[i] == '1') {
co++;
} else {
if (co > 0) {
v.push_back(co);
}
co = 0;
}
}
if (co > 0) {
v.push_back(co);
}
sort(v.rbegin(), v.rend());
if (!v.empty()) {
mxo = v[0];
}
return mxo;
}
void solve() {
int t;
cin >> t;
while (t--) {
int n;
string s;
cin >> n >> s;
int ans = fukc(s);
cout << ans << endl;
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
// #ifndef ONLINE_JUDGE
// freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
// #endif
solve();
return 0;
}