package problem1;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintStream;
import java.util.Arrays;





public class Problem1 {

    public static void main(String[] args) throws FileNotFoundException, IOException{
        try {
             TextIO.readFile("L:\\Coodejam\\Input\\Input.txt");
        }
        catch (IllegalArgumentException e) {
              System.out.println("Can't open file ");
              System.exit(0);
         }
        
        FileOutputStream fout = new FileOutputStream("L:\\Coodejam\\Output\\output.txt");
        PrintStream ps=new PrintStream(fout);
        
        int cases=TextIO.getInt();
        int googlers=0,surprising=0,least=0;
        for(int i=0;i<cases;i++){
            int counter=0;
            googlers=TextIO.getInt();
            surprising=TextIO.getInt();
            least=TextIO.getInt();
            int score[]=new int[googlers];
            for(int j=0;j<googlers;j++){
                score[j]=TextIO.getInt();
                 }
            
            
            
            
            Arrays.sort(score);
            int temp=0;
            int sup[]=new int[surprising];
            
          for(int j=0;j<googlers && surprising>0;j++){
               if(biggestNS(score[j])<least && biggestS(score[j])==least){
                   surprising--;
                   counter++;
                }
               }
           
            for(int j=0;j<googlers;j++){
                if(surprising==0)temp=biggestNS(score[j]);
                    
                else {
                    temp=biggestS(score[j]);
                    surprising--;     
                } 
                   if(temp>=least)counter++;
           
             }
            
             ps.println("Case #"+(i+1)+": "+counter);
        }
    }
    
   static int biggestNS(int x){
       if(x==0)return 0;
       if(x==1)return 1;
       return ((x-1)/3)+1;
   }
   
   static int biggestS(int x){
       if(x==0)return 0;
       if(x==1)return 1;
       return ((x-2)/3)+2;
   }
}
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package googlers;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
/**
 *
 * @author Floran
 */
public class Googlers {

    int nbCase;
	static String inName;
	static String outName;
        public final char h=(char) 104;
	
	public static void solve() throws IOException{
		PrintWriter out=new PrintWriter(new BufferedWriter(new FileWriter(outName)));
		//Scanner in=new Scanner("A-small-practice.txt");
		BufferedReader in=new BufferedReader(new FileReader(inName));
		String ligne=in.readLine();
                // nb de cas
		System.out.println(ligne);
		int nbCase=Integer.parseInt(ligne);
                //compte
                int count=0;
                for(int i=1;i<=nbCase;i++){
                    int ns=0;//nb suprise
                    count=0;
                    String[] parametre=in.readLine().split(" ");
                    System.out.println("lenght"+parametre.length);
                    int nb=Integer.parseInt(parametre[0]);//nb de participant
                    System.out.println("nb"+nb);
                    int suprise=Integer.parseInt(parametre[1]);//nb de triplet surprise
                    System.out.println("sup"+suprise);
                    int min=Integer.parseInt(parametre[2]);//un quote du triplet doit Ãªtre >=min
                    for(int m=3;m<nb+3;m++){
                        //int[][] tab=decomposition(Integer.parseInt(parametre[i]));
                        int[] tab=decomp(Integer.parseInt(parametre[m]));
                        if(tab.length==1){
                            //if(tab[0][2]>=min)
                            if(tab[0]>=min)
                                count++;
                        }
                        else{
                            //if(tab[0][2]>=min)
                            if(tab[0]>=min)
                                count++;
                            //else if(tab[0][2]>=min &&ns<=suprise){
                            else if(tab[1]>=min && ns<suprise){
                                ns++;
                                count++;
                            }
                        }
                    }
                    out.println("Case #"+i+": "+count);	
		}
		out.flush();
		out.close();
		in.close();
	}
   /* public static int[][] decomposition(int quote){
        int mod=quote%3;
        int div=quote/3;
        int[][] tab;
        if(mod==1){
            tab=new int[1][3];
            tab[0][0]=div;
            tab[0][1]=div;
            tab[0][2]=div+1;
            return tab;
        }
        if(mod==2){
            tab=new int[2][3];
            tab[0][0]=div;
            tab[0][1]=div+1;
            tab[0][2]=div+1;
            
            tab[1][0]=div;
            tab[1][1]=div;
            tab[1][2]=div+2;
            
            return tab;
        }
        else{
            tab=new int[2][3];
            tab[0][0]=div;
            tab[0][1]=div;
            tab[0][2]=div;
            
            tab[1][0]=div;
            tab[1][1]=div-1;
            tab[1][2]=div+1;
            
            return tab;
        }
    }*/
    public static int[] decomp(int quote){
        int mod=quote%3;
        int div=quote/3;
        int[] tab;
        if(mod==1){
            tab=new int[1];
            tab[0]=div+mod;
            return tab;
        }
        if(mod==2){
            tab=new int[2];
            tab[0]=div+(mod/2);
            tab[1]=div+mod;
            
            return tab;
        }
        else{
            tab=new int[2];
            tab[0]=div;
            if(quote==0)
                tab[1]=div;
            else
                tab[1]=div+1;
            
            return tab;
        }
    }
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        //inName="A-small-practice.txt";
                //inName="test.txt";
		//outName="solution7.txt";
		inName="B-small-attempt4.in";
		outName="solution_small4.txt";
		//inName="A-large-practice.in";
		//outName="Large_solution.txt";
		try{
			solve();
		}
		catch(IOException e){
			System.out.println(e.getMessage());
		}
		System.out.println("fini");
    }
}
