#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define pb push_back
#define mod 1000000007
#define srt(v) sort(v.begin(),v.end())
#define rsrt(v) sort(v.rbegin(),v.rend())
#define OPTIMIZE_IO ios::sync_with_stdio(false); cin.tie(nullptr);
void solve() {
int n;
cin>>n;
string str;
cin>>str;
for(int i=0; i<str.size();i++){
if(str[i]=='0'){
str[i]='1';
}
else{
str[i]='0';
}
}
ll ans=0,count=0;
for(auto it: str){
if(it=='1'){
count++;
ans=max(ans,count);
}
else{
count=0;
}
}
cout<<ans<<endl;
}
int main() {
OPTIMIZE_IO;
int t;
cin>>t;
while (t--) {
solve();
}
return 0;
}