/**
 * 
 */
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.File;
import java.io.FileNotFoundException;
import java.io.PrintStream;
import java.util.Scanner;


public class GooglerScores {

	
	public static void main(String args[]) throws FileNotFoundException {
		
		//////////////////////////////////////
		// Begin Code Jam regular code      //
		//////////////////////////////////////
		
		Scanner inFile = new Scanner(new File("B-small-attempt0.in"));
		PrintStream outFile = new PrintStream(new File("B-small0-out.txt"));
		
		int numCases = inFile.nextInt();
		inFile.nextLine(); // Gets rid of newline char
		
		//////////////////////////////////////
		// End Code Jam regular code        //
		//////////////////////////////////////
		
		for(int i=1; i<=numCases; i++) {
			
			int numGooglers = inFile.nextInt();
			int maxNumSurprising = inFile.nextInt();
			int leastValid = inFile.nextInt();
			
			int validGooglers = 0;
			int validSurprising = 0;
			
			for(int j=0; j<numGooglers; j++) {
				
				int nextTotal = inFile.nextInt();
				int[] normalScore = calcNormalScore(nextTotal);
				int[] surprisingScore = calcSurprisingScore(nextTotal);
				
				if(hasValidScore(normalScore, leastValid)) {
					validGooglers++;
				} else if (hasValidScore(surprisingScore, leastValid) && validSurprising < maxNumSurprising) {
					validGooglers++;
					validSurprising++;
				}
				
			}
			
			printCase(outFile, i, validGooglers);
			
		}
		
	}
	
	
	private static void printCase(PrintStream outStream, int i, int n) {
		outStream.println("Case #" + i +": " + n);
	}
	
	
	private static int[] calcNormalScore(int totalScore) {
		int[] scores = new int[3];
		if(totalScore % 3 == 0) {
			for(int i=0; i<3; i++) {
				scores[i] = totalScore/3;
			}
		} else if(totalScore % 3 == 1) {
			scores[0] = totalScore / 3;
			scores[1] = scores[0];
			scores[2] = scores[0] + 1;
		} else if(totalScore % 3 == 2) {
			scores[0] = totalScore / 3;
			scores[1] = scores[0] + 1;
			scores[2] = scores[1];
		}
		return scores;
	}
	
	private static int[] calcSurprisingScore(int totalScore) {
		int[] scores = new int[3];
		if (totalScore % 3 == 1 || totalScore <= 0) {
			// There is no such surprising score
			for (int i = 0; i < 3; i++)
				scores[i] = 0;
		} else if (totalScore % 3 == 0) {
			scores[0] = totalScore / 3 - 1;
			scores[1] = totalScore / 3;
			scores[2] = totalScore / 3 + 1;
		} else if (totalScore % 3 == 2) {
			scores[0] = totalScore / 3;
			scores[1] = scores[0];
			scores[2] = scores[0] + 2;
		}
		return scores;
	}
	
	
	private static boolean hasValidScore(int[] scores, int leastValid) {
		for(int i=0; i<scores.length; i++) {
			if(scores[i] >= leastValid) return true;
		}
		return false;
	}
	
}
