#include<stdio.h>
#include<string.h>
#include<iostream>
using namespace std;
#define ll long long int
char a[11500000];
int main()
{
int t;
int kase=0;
scanf("%d",&t);
while(t--)
{
ll k;scanf("%lld",&k);
memset(a,'0',sizeof(a));
scanf("%s",a);
ll output=0;
ll now=0;
int n=strlen(a);
for(ll i=0;i<n;i++)
{
if(i<k)
{
if(a[i]=='1')
now+=(1ll<<((k-1-i)));
}
else
{
now-=(1<<(k-1))*(a[i-k]-'0');
now*=2;
now+=1*(a[i]-'0');
}
output=max(output,now);
}
printf("Case #%d: ",++kase);
printf("%lld\n",output);
}
}