import java.io.*;
import java.util.*;

public class DancingWithGooglers {

  public static class Googlers {

    public int T;
    public int surp;
    public boolean surprising;
    public boolean pSurprising;
    public boolean antiSurprising;
    public boolean pAntiSurprising;

    public Googlers(int T, int surp) {
      this.T = T;
      this.surp = surp;
    }

    public void set(int a, int b, int c) {
      if (c >= 0 && (a + b + c) == T) {
        int diff = (Math.max(a, Math.max(b, c)) - Math.min(a, Math.min(b, c)));
        if (diff <= 2) {
          if (diff == 2) {
            if (a >= surp || b >= surp || c >= surp) {
              pSurprising = true;
            } else {
              surprising = true;
            }
          } else {
            if (a >= surp || b >= surp || c >= surp) {
              pAntiSurprising = true;
            } else {
              antiSurprising = true;
            }
          }
        }
      }
    }
  }

  public static void main(String... args) throws IOException {
//    BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    BufferedReader reader = new BufferedReader(new FileReader("B-large.in"));
//    PrintWriter writer = new PrintWriter(System.out);
    PrintWriter writer = new PrintWriter("B-large.out");

    int len, cases = Integer.parseInt(reader.readLine());
    List<Googlers> satisfied = new ArrayList<Googlers>();
    List<Googlers> unsatisfied = new ArrayList<Googlers>();
    String[] inputs;
    int N, S, p;
    for (int i = 1; i <= cases; i++) {
      inputs = reader.readLine().split(" ");
      p = Integer.parseInt(inputs[1]);
      S = Integer.parseInt(inputs[2]);
      satisfied.clear();
      unsatisfied.clear();
      for (int j = 3; j < inputs.length; j++) {
        int t = Integer.parseInt(inputs[j]);
        Googlers googlers = new Googlers(t, S);

        for (int k = 0; k <= 10; k++) {
          int till = k + 2 > 10 ? 10 : k + 2;
          for (int l = k; l <= till; l++) {
            googlers.set(k, l, (t - (k + l)));
          }
        }
        if (googlers.pAntiSurprising) {
          satisfied.add(googlers);
        } else {
          unsatisfied.add(googlers);
        }
      }
      int pSurprising = 0;
      if (p > 0) {
        for (Iterator<Googlers> iter = unsatisfied.iterator(); iter.hasNext(); ) {
          Googlers googlers = iter.next();
          if (googlers.pSurprising) {
            pSurprising++;
            iter.remove();
            p--;
            if (p <= 0) break;
          }
        }
      }
      if(p > 0){
        for (Iterator<Googlers> iter = unsatisfied.iterator(); iter.hasNext(); ) {
          Googlers googlers = iter.next();
          if (googlers.surprising) {
            iter.remove();
            p--;
            if (p <= 0) break;
          }
        }
      }
      if(p > 0){
        for (Iterator<Googlers> iter = satisfied.iterator(); iter.hasNext(); ) {
          Googlers googlers = iter.next();
          if (googlers.pSurprising) {
            iter.remove();
            pSurprising++;
            p--;
            if (p <= 0) break;
          }
        }
      }
      if(p > 0){
        for (Iterator<Googlers> iter = satisfied.iterator(); iter.hasNext(); ) {
          Googlers googlers = iter.next();
          if (googlers.surprising) {
            iter.remove();
            p--;
            if (p <= 0) break;
          }
        }
      }

      if(p > 0){
        writer.print("Case #" + i + ": 0");
      }else {
        writer.print("Case #" + i + ": " + (satisfied.size() + pSurprising));
      }
      writer.println();
    }
    writer.flush();
  }


}

import java.io.*;
class Main
{
public static int dance(int ll,int spp,int maxx,int g[])
{

int c=0;
int l=ll;
long result[][]=new long[l][4];
int max=maxx;
//int g[]={15,13,11};
int s=0;
int i=0;
int sum=0;
int flag=0;
int t=2;
int presp=spp;
int special=0;
int sp=0;
int sol=0;int maxsol=0;int row=0;
int sum2=0;
boolean yes=true;
for(int loop=0;loop<l;loop++)
{
i=0;
while(i<=10 && flag==0)
{
for(int j=i;j<=i+t && flag==0;j++)
{
for(int k=i;k<=i+t && flag==0;k++)
{
sum=i+j+k;
if(sum==g[loop])
{
sum2=sum;
sol++;
if(j==i+2 || k==i+2)
{
sp++;
special++;
}
//System.out.println(sum+"  ... "+g[loop]);
if(i>=max || j>=max ||k>=max)
{
maxsol++;
//System.out.println(i+ "  "+j+"  "+k);
c++;
flag=0;
}
}

}
}
i++;


/*if(special==presp)
{
t=1;
special=0;
}*/
}
result[row][0]=sum2;
result[row][1]=sol;
result[row][3]=sp;
result[row][2]=maxsol;
row++;
flag=0;
sol=0;
maxsol=0;
sp=0;
}
//System.out.println("ans :"+c);
//System.out.println("special :"+special);
int ans=0;
sort(result,l);
for(int rr=0;rr<l;rr++)
{
if(result[rr][2]>0)
{
presp=rr+presp;
break;
}
}
//System.out.println("presp ="+presp);
for(int rr=0;rr<l;rr++)
{

if(result[rr][2]>0 )
{
if(rr>(presp-1))
{
if(result[rr][3]>=result[rr][2])
{
yes=false;
}
}

if(yes)
ans++;

yes=true;
}
/*
for(int cc=0;cc<4;cc++)
{
//System.out.print(result[rr][cc]+" |  ");
}
System.out.println();*/
}
//System.out.println("ans right:"+ans);
return ans;

}
public static void sort(long a[][],int l)
{
long cell1=0,cell2=0,cell3=0,cell4=0;
for(int i=0;i<l;i++)
{
for(int j=i+1;j<l;j++)
{
if(a[i][2]>a[j][2])
{
cell1=a[i][0];
cell2=a[i][1];
cell3=a[i][2];
cell4=a[i][3];

a[i][0]=a[j][0];
a[i][1]=a[j][1];
a[i][2]=a[j][2];
a[i][3]=a[j][3];

a[j][0]=cell1;
a[j][1]=cell2;
a[j][2]=cell3;
a[j][3]=cell4;

}

}
}
}
public static void main(String ar[]) throws IOException
{
FileReader in=new FileReader("hello.txt");
FileWriter ot=new FileWriter("check.txt",true);

BufferedReader ds=new BufferedReader(in);
BufferedWriter out=new BufferedWriter(ot);

//System.out.println("check332wefsd");
int loop=Integer.parseInt(ds.readLine());
String i[]=new String[loop];
int ll,maxx,sp;
int rs[];
int ans;
for(int ii=1;ii<=loop;ii++)
{
i=ds.readLine().split(" ");
ll=Integer.parseInt(i[0]);
sp=Integer.parseInt(i[1]);
maxx=Integer.parseInt(i[2]);
rs=new int[ll];
for(int j=3;j<ll+3;j++)
{
rs[j-3]=Integer.parseInt(i[j]);
}
ans=dance(ll,sp,maxx,rs);
out.write("Case #"+String.valueOf(ii)+": "+String.valueOf(ans));
out.newLine();

}
in.close();
out.close();

}
}