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

public class DancingGooglers {
	private static Scanner inFile;
	private static PrintWriter outFile;
	private static final String FILE_NAME = "B-small-attempt0";
	
	/* Copy & Paste: VARIABLES */
	
	private static int numCases, numGooglers, surpriseScores, bestScore, totalScore, trio, score1, score2, score3, answer;
	private static boolean trioFound;
	
	/* Copy & Paste: VARIABLES */
	
	public static void main(String[] args) throws IOException {
		inFile = new Scanner(new File(FILE_NAME + ".in"));
		outFile = new PrintWriter(FILE_NAME + ".out");
		
		numCases = inFile.nextInt();
		
		for (int caseNum = 0; caseNum < numCases; caseNum++) {
			numGooglers = inFile.nextInt();
			surpriseScores = inFile.nextInt();
			bestScore = inFile.nextInt();
			answer = 0;
			
			for (int googlerNum = 0; googlerNum < numGooglers; googlerNum++) {
				totalScore = inFile.nextInt();
				trioFound = false;
				
				if (bestScore > 0) {
					trio = 28 - (27 - ((bestScore - 1) * 3));
					score1 = bestScore;
					score2 = bestScore - 1;
					score3 = score2;
				}
				else {
					trio = 0;
					score1 = 0;
					score2 = 0;
					score3 = 0;
				}
				
				for (trio = trio; trio < 31 && !trioFound; trio++) {
					if (score1 + score2 + score3 == totalScore) {
						answer++;
						trioFound = true;
					}
					else {
						if (trio % 3 == 0) {
							score1++;
						}
						else if (trio % 3 == 1) {
							score2++;
						}
						else {
							score3++;
						}
					}
				}
				
				if (bestScore >= 2 && (totalScore - 1) % 3 != 0 && !trioFound) {
					
					score1 = bestScore;
					score2 = bestScore - 2;
					score3 = score2;
					
					for (trio = (bestScore - 2) * 2; trio < 18 && !trioFound && surpriseScores > 0; trio++) {
						if (score1 + score2 + score3 == totalScore) {
							answer++;
							surpriseScores--;
							trioFound = true;
						}
						else {
							if (trio % 2 == 0) {
								score2++;
							}
							else {
								score1++;
								score3++;
							}
						}
					}
				}
			}
			
			outFile.printf("Case #%d: %d\n", caseNum + 1, answer);
		}
		
		inFile.close();
		outFile.close();
		System.out.println("Succesfully written to " + FILE_NAME + ".out.");
	}
}
