import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;


public class Dancing {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		// read input file
		File file = new File("B-small-attempt4.in");
		//File file = new File("input.txt");
		BufferedReader br = new BufferedReader(new FileReader(file));
		String ln = "";
		int count = Integer.parseInt(br.readLine());

		// write output file
		File out = new File("outB.txt");
		BufferedWriter bw = new BufferedWriter(new FileWriter(out));
		
		int y = 0;
		for (int i=0; i < count; i++){
			ln = br.readLine();
			y = getY(ln);
			bw.write("Case #" + (i+1) + ": " + y);
			bw.newLine();
		}
		bw.close();
	}
	
	private static int getY(String str) {
		String[] data = str.split(" ");
		int n = Integer.parseInt(data[0]);
		int s = Integer.parseInt(data[1]);
		int p = Integer.parseInt(data[2]);
		int[] t = new int[n];
		for (int i=0; i < n; i++){
			t[i] = Integer.parseInt(data[i+3]);
		}
		int y = 0;
		int base = 0;
		for(int j=0; j < t.length; j++){
			base = t[j] / 3;
			if(base >= p) { y++; }
			else if(base == p-1){
				if(t[j] - (base+p) > base-1 && t[j] > 0){
					y++;
				} else if(s>0 && t[j] - (base+p) > base-2 && t[j] > 0){
					s -= 1;
					y++;
				}
			} else if(base == p-2){
				if(s > 0 && t[j] - (base+p) > base-1 && t[j] > 0){
					s -= 1;
					y++;
				}
			}
		}
		
		return y;
	}

}

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.InputStreamReader;
import java.util.ArrayList;

/**
 * 
 */

/**
 * @author Bryan
 *
 */
public class problemB {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		String filePath = "/Users/Bryan/Documents/CodeJam/ProblemB/B-small-attempt0.in";
		boolean isFirstLine = true;
		int counter = 1;
		StringBuffer resultString = new StringBuffer();
		
		try {
			// Open the file that is the first
			// command line parameter
			FileInputStream fstream = new FileInputStream(filePath);
			// Get the object of DataInputStream
			DataInputStream in = new DataInputStream(fstream);
			BufferedReader br = new BufferedReader(new InputStreamReader(in));
			String strLine;
			// Read File Line By Line
			while ((strLine = br.readLine()) != null) {
				if (isFirstLine){
					isFirstLine = false;
					continue;
				}
				int maxNoGoogler = 0;
				
				resultString.append("Case #" + counter + ": ");
				String[] numberList = strLine.split(" ");
				int noOfGoogler = Integer.parseInt(numberList[0]);
				int noOfSuprise = Integer.parseInt(numberList[1]);
				int individualTarget = Integer.parseInt(numberList[2]);
//				ArrayList<Integer> totalScoreList = new ArrayList<Integer>();
				for ( int a = 3; a < numberList.length; a++){
//					totalScoreList.add(Integer.parseInt(numberList[a]));
					if ( Integer.parseInt(numberList[a]) >= miniTotal(noOfGoogler, individualTarget) ){
						maxNoGoogler++;
					}else if ( noOfSuprise > 0 && Integer.parseInt(numberList[a]) >= miniTotalWithSuprise(noOfGoogler, individualTarget) ){
						noOfSuprise--;
						maxNoGoogler++;
					}
				}
				
				resultString.append(maxNoGoogler);
				resultString.append("\n");
				counter++;
			}
			// Close the input stream
			in.close();
		} catch (Exception e) {// Catch exception if any
			System.err.println("Error: " + e.getMessage());
		}
		
		writeStringToFile(resultString.toString());


	}
	
	private static int miniTotalWithSuprise(int noOfGoogler, int individualTarget){
		int min = (3 * individualTarget) - (2 * (3 - 1));
		
		if ( min < individualTarget){
			return individualTarget;
		}
		
		return min;
	}
	
	private static int miniTotal(int noOfGoogler, int individualTarget){
		int min = (3 * individualTarget) - (3 - 1);
		if ( min < individualTarget){
			return individualTarget;
		}
		return min;
	}
	
	private static void writeStringToFile(String outputString) {
		try {
			// Create file
			FileWriter fstream = new FileWriter("/Users/Bryan/Documents/CodeJam/ProblemB/output.txt");
			BufferedWriter out = new BufferedWriter(fstream);
			out.write(outputString);
			// Close the output stream
			out.close();
		} catch (Exception e) {// Catch exception if any
			System.err.println("Error: " + e.getMessage());
		}
	}

}
