#ifndef LOCAL
#include <bits/stdc++.h>
#define debug(...)
#endif
using namespace std;
#define int long long
#define cinv(v) for (auto &it:v) cin>>it;
#define coutv(v) for (auto &it:v) cout<< it<<' '; cout<<'\n';
void shelby() {
int n;
string s;
cin >> n >> s;
int ans = 0, now = 0;
for (auto &it: s) {
if (it == '1') {
ans = max(ans, now);
now = 0;
}
else now++;
debug(ans, it, now);
}
ans = max(ans, now);
cout << ans << '\n';
}
signed main() {
cin.tie(0)->sync_with_stdio(0);
int t = 1;
cin >> t;
for (int _ = 1; _ <= t; ++_) {
// cout << "Case " << _ << ": ";
shelby();
}
}