//#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <bits/stdc++.h>
typedef long long int LL;
using namespace std;
#define abs(x) ((x)>0?(x):-(x))
const int N = 1e6+7;
/*****************************************************************/
#define create_date1
#ifdef create_date
int k;
void print(LL x){
for(int i=k-1;i>=0;i--){
if(x&(1ll<<i)) printf("1");
else printf("0");
}
}
int main(){
freopen("input8.txt","w",stdout);
srand(time(NULL)+19970622.);
int _ = 10;
printf("%d\n",_);
for(;_--;){
k=60; printf("%d\n",k);
for(int i=1000000/60;i;i--) print(rand()*rand());
for(int i=1000000-1000000/60*60;i;i--){
if(rand()%2) printf("1");
else printf("0");
}
puts("");
}
return 0;
}
#else
char s[N];
int k;
void print(LL x){
for(int i=k-1;i>=0;i--){
if(x&(1ll<<i)) printf("1");
else printf("0");
}
puts("");
}
int main(){
// freopen("input8.txt","r",stdin);
// freopen("output8.txt","w",stdout);
int _=1,kcase=0;
scanf("%d",&_);
while(_--){
scanf("%d",&k);
scanf("%s",s);
int l=strlen(s);
LL x=0,mx=0;
for(int i=l-k+1;i<l;i++){
x<<=1;
x|= s[i]=='1' ;
}
for(int i=l-k;i>=0;i--){
if(s[i]=='1') x|=1LL<<(k-1);
mx=max(mx,x);
// printf("mx = %lld x = %lld ",mx,x);
// print(x);
x>>=1;
}
printf("Case #%d: %lld\n",++kcase,mx);
// print(mx);
}
return 0;
}
#endif // create_date
/**
10
5
10101110101011101011111
*/