/**
 * 
 */
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.io.*;
import java.util.LinkedList;
class firstgame21 
{
	BufferedReader br;
	PrintWriter pw;

	String input;
	int totalpass;

	public firstgame21()
	{
		try
		{
			br = new BufferedReader(new FileReader("B-small-attempt0.in"));
			pw = new PrintWriter(new BufferedWriter(new FileWriter("output1.txt")));		

			
			input = br.readLine();
			int count = Integer.parseInt(input);

			for (int x=1; x<= count; x++)
			{
				totalpass = 0;
				input = br.readLine();
				String data[] = input.split(" ");
				int people = Integer.parseInt(data[0]);
				int extra = Integer.parseInt(data[1]);
				int min = Integer.parseInt(data[2]);

				for (int y = 0; y< people ; y++ )
				{
					int p = Integer.parseInt(data[3+y]);
					int max;
					if (p%3==0)
					{
						 max = p/3;
				//System.out.println("max1:"+max);
						 if (max >= min)
						 {
							 totalpass++;
						 }
						 else if (max + 1 == min)
						 {
							 if (max == 0)
							 {
							 }
							 else if (extra > 0)
							 {
							 totalpass++;
							 extra-- ;
							 }
						 }
					}
					else if (p%3==1)
					{
						 max = (p/3) + 1;
				//System.out.println("max2:"+max);
						 if (max >= min)
						 {
							 totalpass++;
						 }
					}
					else if (p%3==2)
					{
						 max = (p/3) + 1;
				//System.out.println("max3:"+max);
						 if (max >= min)
						 {
							 totalpass++;
						 }
						 else if (max+1 == min)
						 {
							 if (extra > 0)
							 {
							 totalpass++;
							 extra-- ;
							 }
						 }
					}
				}

				System.out.println("Case #"+x+": "+totalpass);
				pw.println("Case #"+x+": "+totalpass);
			}
			// after end read
			pw.close();
		}
		catch (IOException e)
		{
			System.out.println(e);
		}	
	}
	public static void main(String[] args) 
	{
		new firstgame21();
	}
}
