#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int maxLengthOfZeros(string& s) {
int max_len = 0, current_len = 0;
for (char ch : s) {
if (ch == '0') {
current_len++;
} else {
max_len = max(max_len, current_len);
current_len = 0;
}
}
max_len = max(max_len, current_len);
return max_len;
}
void solve()
{
ll n;
cin >> n;
string s;
cin>>s;
cout<<maxLengthOfZeros(s)<<endl;
}
int main()
{
int tc = 1, cs = 1;
cin >> tc;
while (tc--)
{
// cout<<"Case "<<cs<<": ";
solve();
}
return 0;
}