import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;


public class GooglersDancer {

	/**
	 * @param args
	 * @throws IOException
	 */
	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		InputStreamReader converter = new InputStreamReader(System.in);
		BufferedReader in = new BufferedReader(converter);
		if (in == null) {
		      return;
		    }
		String numTest = in.readLine();
		int maxCases = Integer.valueOf(numTest);
		for(int i=1;i<= maxCases;i++){
			String linea = in.readLine();
			String[] datos = linea.split(" ");
			Integer googlers = Integer.valueOf(datos[0]);
			Integer sospechosos = Integer.valueOf(datos[1]);
			Integer p = Integer.valueOf(datos[2]);
			Integer puntuacion;
			Integer personas = 0;
			ArrayList<Integer> puntuaciones = new ArrayList<Integer>();
			for(int j=0;j<googlers;j++){
				puntuacion = Integer.valueOf(datos[3+j]);
				puntuaciones.add(puntuacion);
			}
			Integer[] pOrdenado = null;
			pOrdenado = (Integer[]) puntuaciones.toArray(new Integer[puntuaciones.size()]);
			Arrays.sort(pOrdenado);
			int j;
			for(j=pOrdenado.length-1;j>=0;j--){
				if(pOrdenado[j] >= p*3-2){
					personas += 1;
				}else{
					break;
				}
			}
			int posibles = j+1-sospechosos;
			for(;j>=posibles && j>= 0;j--){
				if(pOrdenado[j] >= p*3-4 && pOrdenado[j] > p){
					personas += 1;
				}else{
					break;
				}
			}
			System.out.println("Case #"+i+": "+personas);
		}
	}

}

import java.io.*;
public class DancingWithTheGooglers
{
	public static void main(String [] args) throws Exception
	{
		BufferedReader br = new BufferedReader(new FileReader("BBI.txt"));

		String write = "";
		int i = Integer.parseInt(br.readLine());

		for(int j = 1; j <= i; j++)
		{
			String ra = br.readLine();
			int c = 0;

			Integer [] ir = c(ra.split(" "));
			int S = ir[1];
			for(int k = 0; k < ir[0]; k++)
			{
				boolean flag = false;
				int score = ir[k + 3];
				int [] triplet = new int[3];
				
				for(int l = 0; l < 3; l++) 
				if(score >= 0)
				{
					triplet [l] = score / (3 - l);
					score = score - triplet[l];
					if(triplet[l] >= ir[2])
					{
						c = c + 1;
						flag = true;
						break;
					}
					
				}

				if(S > 0)
				{
					for(int m = 1; m < 3; m++)
					{
						if(!flag && triplet[m-1] > 0)
						if(triplet[m] == triplet[m - 1])
						{
							triplet[m] = triplet[m] + 1;
							triplet[m-1] = triplet[m-1] - 1;
							if(triplet[m] >= ir[2])
							{
								c = c + 1;
								S = S - 1;
							}
							break;
						}
					}

				}
				
			}

			String newLine = "\n";
			if(j == i)
				newLine = "";
			write = write + "Case #" + j + ": " + c + newLine;
			//System.out.println("Case #" + j + ": " + c);
		}

		BufferedWriter bw = new BufferedWriter(new FileWriter("BBO.txt"));
		bw.write(write);
		bw.flush();
		bw.close();
		System.out.println(write);
	}

	static Integer [] c(String [] args)
	{
		Integer [] array = new Integer[args.length];
		for(int i = 0; i < args.length; i++)
		{
			array [i] = Integer.parseInt(args[i]);
		}
		return array;
	}

}