#include <iostream>
#include <fstream>
#include <string.h>
using namespace std;
char v[1000000000];
int t,n,m;
long long int counter=0;
char s[1100];
int Verificare(){
if(strstr(v,s)==NULL)
return 1;
return 0;
}
void RecBk(int k){
for(int i=0;i<=1;i++){
int p[1];
p[0]=char(48+i);
v[k]=p[0];
if(k==n-1){
v[n]='\0';
if(Verificare()){
counter++;
}
}else{
RecBk(k+1);
}
}
}
int main(){
fstream f("traseu.in",ios::in);
fstream g("traseu.out",ios::out);
f>>t;
int o=t;
while(t!=0){
f>>n;
f>>m;
cin.get(s,100);
cin.get();
RecBk(0);
g<<"Case #"<<o-t+1<<": "<<counter<<endl;
counter=0;
t--;
}
g.close();
f.close();
system("pause");
}