#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define ll long long int
#define N (ll)1e6
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll t=1,i=1,j,p,mx,tot,n,a,m,x,y,k,rt,c,b=1;
cin>>t;
while(t--){
cin>>n;
string s;
cin>>s;
ll cnt=0,mx=0;
for(a=0;a<s.size();a++){
if(s[a]=='0')
cnt++;
else{
mx=max(mx,cnt);
cnt=0;
}
}
mx=max(mx,cnt);
cout<<mx<<endl;
}
}