/**
 * Created by IntelliJ IDEA.
 * User: Administrator
 * Date: 3/3/12
 * Time: 11:00 AM
 * To change this template use File | Settings | File Templates.
 */

import SRMLib.MathLibrary;
import SRMLib.TestSRMLib;
import com.sun.org.apache.bcel.internal.generic.F2D;

import java.io.*;
import java.util.*;
import java.util.zip.Inflater;

public class SRM {
    public static void main(String[] args) throws IOException {
        //TestSRMLib.run();
        codeJam1.main();

        return;
    }
}
class codeJam1 {
    public static void main() throws IOException {
        String inputPath = "E:\\input.txt";
        String outputPath = "E:\\output.txt";
        BufferedReader input = new BufferedReader(new FileReader(inputPath));
        BufferedWriter output = new BufferedWriter(new FileWriter(outputPath));

        String line;
        line = input.readLine();
        int T = Integer.parseInt(line);
        for (int i = 1; i <= T; ++i) {
            line = input.readLine();
            String[] words = line.split(" ");
            int N = Integer.parseInt(words[0]);
            int S = Integer.parseInt(words[1]);
            int p = Integer.parseInt(words[2]);
            int n = 0;
            int res = 0;

            for (int j = 3; j < words.length; ++j) {
                if (p == 0) {
                    res++;
                    continue;
                }

                int t = Integer.parseInt(words[j]);
                if (p == 1) {
                    if (t > 0)
                        res++;
                    continue;
                }
                if (t >= 3 * p - 2)
                    res++;
                else if (t >= 3 * p - 4)
                    n++;
            }

            res += Math.min(n, S);
            output.write("Case #" + i + ": " + res);
            output.newLine();
        }

        input.close();
        output.close();
    }
}

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
//package codejam.practice;

/**
 *
 * @author Saikat Roy
 */
import java.io.*;
public class Main1 {
  BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

    public void input() throws IOException
    {
       int k=1;
       int n=Integer.parseInt(br.readLine());
       while(n--!=0)
       {
           String str1=br.readLine();
           String[] str2=new String[40];
           str2=str1.split("[ ]");
           
           int N=Integer.parseInt(str2[0]);
           int S=Integer.parseInt(str2[1]);
           int p=Integer.parseInt(str2[2]);
           int x=0;
           int[] arr=new int[N];
           while(x<N){
               arr[x]=Integer.parseInt(str2[x+3]);
               x++;
           }
           
           for(int k1=0;k1<N-1;k1++)
               for(int k2=k1+1;k2<N;k2++)
                   if(arr[k2]<arr[k1])
                   {
                       int hold=arr[k1];
                       arr[k1]=arr[k2];
                       arr[k2]=hold;
                   }
           
           
           
          // for(int m=0;m<N;m++)
          // System.out.print(arr[m]+" ");
               

           int flag=0;
           int[] check=new int[6];
           check[0]=(3*p)-4;
           check[1]=(3*p)-3;
           check[2]=(3*p)-2;
           check[3]=(3*p)+2;           
           check[4]=(3*p)+3;
           check[5]=(3*p)+4;
           
           String[] allocation=new String[N];
           
           for(int y=0;y<N;y++){
               allocation[y]="A";
               if(p>1)
               if(((arr[y]==check[0])||(arr[y]==check[1]||(arr[y]==check[2])))&&(S!=0))
               {
                   //System.out.println(y);
                   flag++;
                   S--;
                   //allocation[y]="";
                   allocation[y]="X";
               }
            }
           
           
          
           if(S!=0){
              for(int y=0;y<N;y++){
               if(((arr[y]==check[3])||(arr[y]==check[4]||(arr[y]==check[5])))&&(S!=0))
               {
                //   System.out.println("x");
                   flag++;
                   S--;
                   //allocation[y]="";
                   allocation[y]="X";
               }
            } 
           }
           
           int chk=(3*p)-2;
           if(p==0)
               chk=0;
           
           
           for(int y=0;y<N;y++){
             //  System.out.println(allocation[y]);
               if(arr[y]>=chk && allocation[y].equals("A"))
               {
                   //System.out.println("x");
                   flag++;
                  //allocation[y]="";
                   allocation[y]="X";
               }
           }
           //if(S!=0)
              // flag-=S;
           
          // for(int y=0;y<N;y++)
            //   System.out.println(allocation[y]);
           
           System.out.print("Case #"+k+": "+flag);
             if(n!=0)
           System.out.println();
           k++;
       }
    }
     
    public static void main(String[] args) throws IOException {
        Main1 ob=new Main1();
        ob.input();
    }
}
