#include <bits/stdc++.h>
using namespace std;
#define ZORO ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long
const int M = 3e5 + 5, MOD = 998244353;
int gcd(int a,int b)
{
while(b != 0)
{
int temp = a % b;
a = b;
b = temp;
}
return a;
}
void solve(){
int n;
cin>>n;
string s;
cin>>s;
int ans = 0;
int left = 0,right = 0;
for(int i=0; i<n ;i++){
if(s[i] == '1'){
right++;
int mx = right - left;
ans = max(ans,mx);
}
else{
left = i;
right = i;
}
}
int emon = n /2;
ans /= emon;
int t = 1;
cout<<max(ans,t)<<endl;
}
int32_t main()
{
ZORO
int tt;
cin>>tt;
while(tt--)
{
solve();
}
return 0;
}