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.BufferedReader;
import java.io.FileReader;
import java.io.FileWriter;
import java.util.StringTokenizer;

public class GoogleDancers{

	public static void main(String[] args) throws Exception{
		FileReader fr = new FileReader("C:\\Projects\\Learning\\src\\B-large.in");
		BufferedReader br = new BufferedReader(fr);
		FileWriter fw = new FileWriter("C:\\Projects\\Learning\\src\\BLarge.txt");
		int N = new Integer(br.readLine());
		for (int cases = 1; cases <= N; cases++) {
			String str = br.readLine();
			StringTokenizer st = new StringTokenizer(str); 
			int numberParticipants = Integer.parseInt(st.nextToken());
			int surprise = Integer.parseInt(st.nextToken()); 
			int goodScore = Integer.parseInt(st.nextToken());
			int a[] = new int[numberParticipants];
			for(int i=0; i< numberParticipants; i++) {
				a[i] = Integer.parseInt(st.nextToken());
			}
			int count = 0;
			int possibility = 0;
			int minToGetGoodScore = Math.max(((3 * goodScore) - 2), 1);
			System.out.println("minToGetGoodScore" + minToGetGoodScore);
			int surpriseRange = Math.max(((3* goodScore) - 4), 1);
			if (goodScore > 0 ) {
				for (int i = 0; i < numberParticipants; i++) {
					if (a[i] >= minToGetGoodScore) {
						count++;
						System.out.println("Count" + count);
						

					} else if (a[i] >= surpriseRange
							&& a[i] < minToGetGoodScore) {
						possibility++;
					}
				}System.out.println("Count" + count);
				count = count + Math.min(possibility, surprise);
				System.out.println("Count" + count);
			}
			else
			{
				count = numberParticipants;
			}
			fw.write("Case #" + cases + ": " + count + "\n");
			
		}
		fw.flush();
		fw.close();
	}
}
