/**
 * 
 */
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.ArrayList;
import java.util.HashSet;


public class DancingWithTheGooglers {
private static String inputFile = "C:\\PERSONAL-WORKSPACE\\GCJ-2012\\src\\input-output\\Input.txt";
private static String outputFile = "C:\\PERSONAL-WORKSPACE\\GCJ-2012\\src\\input-output\\Output.txt";
public static void main(String[] args) {
	InputReader ir = new InputReader(inputFile);
	OutputWriter ow = new OutputWriter(outputFile);
	ArrayList<String> lines = ir.loadLines();	
	for(int i=1;i<lines.size();i++){
		int count = 0;
		Long[] arrL = GCJUtils.getLongArray(lines.get(i).split(" ",lines.get(i).length()));		
		long nst = arrL[1];
		long score = arrL[2]; 
		ArrayList<Long[]> al = new ArrayList<Long[]>();
		for(int j=3;j<arrL.length;j++){		
			Long[] scoresArr = new Long[3];
			long remainder = arrL[j]%3;
			long tmp = arrL[j]/3;			
			scoresArr[0] = scoresArr[1] = scoresArr[2] = tmp;
			for(int k=0;k<remainder;k++){
				scoresArr[k]++;
			}
			if(scoresArr[0] >=score || scoresArr[1] >=score ||scoresArr[2] >=score){
				count++;
			}else if(remainder!=1 ){
				al.add(scoresArr);
			}
		}
		for(int p=0;p<al.size();p++){
			Long[] arrLL = al.get(p);
			if(nst==0)break;
			if(arrLL[0]!=0 && arrLL[0]==(score-1)){
				count++;nst--;
			}
		}
		ow.writeCaseLine(count+"");
	}
	ow.flushAndClose();
}
}
