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;
   }
}

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

/**
 *
 * @author Hilos
 */
public class ProblemB {

    public static BufferedWriter bw;
    public static BufferedReader br;

    public static void main(String[] args) {
        try {
            String filename = "B-small-attempt0";
            br = new BufferedReader(new FileReader("E:\\Downloads\\" + filename + ".in"));
            bw = new BufferedWriter(new FileWriter("E:\\Downloads\\" + filename + ".out"));

            int caseCount = Integer.parseInt(br.readLine());

            for (int c = 0; c < caseCount; c++) {
                String[] lineParts = br.readLine().split(" ");

                int N = Integer.parseInt(lineParts[0]);
                int S = Integer.parseInt(lineParts[1]);
                int p = Integer.parseInt(lineParts[2]);

                int[] scores = new int[N];

                for (int s = 0; s < N; s++) {
                    scores[s] = Integer.parseInt(lineParts[3 + s]);
                }

                SolveCase(c + 1, N, S, p, scores);
            }


        } catch (Exception exc) {
            System.out.println(exc.toString());
        }
    }

    public static void SolveCase(int caseNumber, int N, int S, int p, int[] scores) throws Exception {

        int aboveOrEqual = 0;
        int surprisingLeft = S;

        int scoreCount = scores.length;
        for (int s = 0; s < scoreCount; s++) {
            int score = scores[s];

            if(score == 0){
                if(p == 0){
                    aboveOrEqual++;   
                }
            }else  if (score % 3 == 1) {
                if ((score + 2) / 3 >= p) {
                    aboveOrEqual++;
                }
            } else if (score % 3 == 0) {
                if ((score / 3) >= p) {
                    aboveOrEqual++;
                } else if (surprisingLeft > 0 && (score / 3) + 1 >= p) {
                    aboveOrEqual++;
                    surprisingLeft--;
                }
            } else if (score % 3 == 2) {
                if (((score + 1) / 3) >= p) {
                    aboveOrEqual++;
                } else if (surprisingLeft > 0 && ((score + 1) / 3) + 1 >= p) {
                    aboveOrEqual++;
                    surprisingLeft--;
                }
            }
        }

        bw.write("Case #" + caseNumber + ": " + aboveOrEqual + "\n");
        bw.flush();
    }
}
