package codejam;

import fixjava.Pair;

public class Utils {

	public static long minLong(long firstVal, long... otherVals) {
		long minVal = firstVal;
		for (int i = 0; i < otherVals.length; i++)
			minVal = Math.min(firstVal, otherVals[i]);
		return minVal;
	}

	public static int minInt(int firstVal, int... otherVals) {
		int minVal = firstVal;
		for (int i = 0; i < otherVals.length; i++)
			minVal = Math.min(firstVal, otherVals[i]);
		return minVal;
	}

	public static float minFloat(float firstVal, float... otherVals) {
		float minVal = firstVal;
		for (int i = 0; i < otherVals.length; i++)
			minVal = Math.min(firstVal, otherVals[i]);
		return minVal;
	}

	/**
	 * ArgMin returned as a Pair<Integer, Integer>(index, value). Array must
	 * have at least one value.
	 */
	public static Pair<Integer, Integer> argMin(int[] arr) {
		int min = arr[0];
		int argMin = 0;
		for (int i = 1; i < arr.length; i++) {
			if (arr[i] < min) {
				min = arr[i];
				argMin = i;
			}
		}
		return new Pair<Integer, Integer>(argMin, min);
	}

	/**
	 * ArgMax returned as a Pair<Integer, Integer>(index, value). Array must
	 * have at least one value.
	 */
	public static Pair<Integer, Integer> argMax(int[] arr) {
		int max = arr[0];
		int argMax = 0;
		for (int i = 1; i < arr.length; i++) {
			if (arr[i] > max) {
				max = arr[i];
				argMax = i;
			}
		}
		return new Pair<Integer, Integer>(argMax, max);
	}

}

import java.io.BufferedWriter;
import java.io.File;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.FileSystems;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardOpenOption;
import java.util.Scanner;

public class QB {
	public static int cal(Scanner sc){
		int result = 0;
		
		int N = sc.nextInt();
		int S = sc.nextInt();
		int p = sc.nextInt();
	
		if(p > 1){
			int tmp1 = p*3-2;
			int tmp2 = tmp1-2;
			for(int i=0; i<N; i++){
				int t = sc.nextInt();
				if(t >= tmp1){
					result++;
				} else if(t >= tmp2 && S > 0){
					S--;
					result++;
				}
			}
		} else if(p == 1){
			for(int i=0; i<N; i++){
				int t = sc.nextInt();
				if(t != 0){
					result++;
				}
			}
		} else if(p == 0){
			for(int i=0; i<N; i++){
				int t = sc.nextInt();
				result++;
			}
		}
		
		return result;
	}
	public static void main ( String [] args ) throws IOException
	{
		Scanner sc = new Scanner(new File("B-large.in"));
		Path file = FileSystems.getDefault().getPath(".", "B-large-practice.out");
		BufferedWriter writer = Files.newBufferedWriter(file, StandardCharsets.US_ASCII, StandardOpenOption.CREATE);
		
		int t = sc.nextInt();
		for(int i=0; i<t; i++){
			String output = String.format("Case #%d: %d\n", i+1, cal(sc));
			writer.write(output);
		}
		sc.close();
		
		writer.flush();
		writer.close();
	}
}