/**
 * 
 */
package pandit.codejam;

import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.util.Scanner;

/**
 * @author Manu Ram Pandit
 * 
 */
public class DancingWithGooglersUpload {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		FileInputStream fStream = new FileInputStream(
				"input.txt");

		Scanner scanner = new Scanner(new BufferedInputStream(fStream));
		Writer out = new OutputStreamWriter(new FileOutputStream("output.txt"));

		int T = scanner.nextInt();
		int N,S,P,ti;
		int counter = 0;
		for (int count = 1; count <= T; count++) {
			N=scanner.nextInt();
			S = scanner.nextInt();
			counter = 0;
			P = scanner.nextInt();
			for(int i=1;i<=N;i++){
				ti=scanner.nextInt();
				if(ti>=(3*P-2)){
					counter++;
					continue;
				}
				else if(S>0){
					if(P>=2 && ((ti==(3*P-3)) ||(ti==(3*P-4)))) {
					S--;
					counter++;
					continue;
					}
				}
				
			}
			// System.out.println("Case #" + count + ": " + counter);
			out.write("Case #" + count + ": " + counter + "\n");
		}
		fStream.close();
		out.close();

	}

}

import java.io.*;

public class Qualifying_B {

	public static void main(String[] args) throws Exception {
        BufferedReader input = new BufferedReader(new FileReader(args[0]));
        int T = Integer.parseInt(input.readLine());
        
        for (int t = 1; t <= T; t++) {
        	String[] tokens = input.readLine().split(" ");
        	
        	int N = Integer.parseInt(tokens[0]);
        	int S = Integer.parseInt(tokens[1]);
        	int p = Integer.parseInt(tokens[2]);
        	int[][] Googlers = new int[N][3];
        	
        	for (int n = 0; n < N; n++) {
        		Googlers[n][0] = Integer.parseInt(tokens[3 + n]);
        		Googlers[n][1] = Googlers[n][0] / 3 + ((Googlers[n][0] % 3 != 0) ? 1 : 0);
        		Googlers[n][2] = (Googlers[n][0] < 2 || Googlers[n][0] > 28) ? -1 : (Googlers[n][0] - 2) / 3 + 2;
        	}

        	int m = 0;
        	
        	for (int n = 0; n < N; n++) {
        		if (Googlers[n][1] >= p)
        			m++;
        		else if (Googlers[n][2] >= p && S > 0) {
        			S--;
        			m++;
        		}
        	}
        	
        	System.out.println("Case #" + t + ": " + m);
        }		
	}
}
