import java.io.BufferedWriter;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Scanner;


public class Dancing_With_the_Googlers {


    /**
     * The first line of the input gives the number of test cases, T.
     *  T test cases follow. 
     *  Each test case consists of a single line containing integers separated by single spaces. 
     *  The first integer will be N, the number of Googlers, and the second integer will be S, the number of surprising triplets of scores. 
     *  The third integer will be p, as described above. Next will be N integers ti: the total points of the Googlers. 
     * @throws IOException
     */
	   public static void main(String[] args) throws IOException {
	        // TODO Auto-generated method stub
			// Reading the input file
			Scanner in = new Scanner(new File("B-large.in"));
			// writting the input file
			FileOutputStream fos = new FileOutputStream("B-large.out");
			PrintStream out = new PrintStream(fos);
	         //Close the output stream
	        int testCase=Integer.parseInt(in.nextLine());
	        for(int i=0;i<testCase;i++) {
	        	out.print("Case #" + (i + 1) + ":\t");
	        	int NoOfGooglers= in.nextInt();
	        	int NoOfSurprisingResults = in.nextInt();
	        	int atLeastP=in.nextInt();
	        	ArrayList<Integer> scores= new ArrayList<Integer>();
        		int BestResults=0;
        		int Surprising=0;
	        	for(int j=0;j<NoOfGooglers;j++)
	        	{
	        		scores.add(in.nextInt());
	        		//System.out.print(scores.get(j));
	        		int modulus=scores.get(j)%3;
	        		int temp = scores.get(j);
	    			switch (modulus) {
					case 0:
						if (((temp / 3) >= atLeastP)) {
							BestResults++;
						} else {
							if (((((temp / 3) + 1) >= atLeastP) && ((temp / 3) >= 1))
									&& (Surprising < NoOfSurprisingResults)) {
								BestResults++;
								Surprising++;
								
							}
							System.out.println("Case 0"+"itr:"+i+"  surprising:"+temp);
						}
						
						break;
					case 1:
						if ((temp / 3) + 1 >= atLeastP) {
							BestResults++;
							continue;
						}
						
						break;
					case 2:
						if ((temp / 3) + 1 >= atLeastP) {
							BestResults++;
						} else {
							if (((temp / 3) + 2 >= atLeastP)
									&& (Surprising < NoOfSurprisingResults)) {
								BestResults++;
								Surprising++;
							}
							System.out.println("Case 2"+"itr:"+i+"  surprising:"+temp);
						}
						break;
					default:
						System.out.println("Error");
					}
	    			
				}// Internal for
				out.println(BestResults);
				// System.out.println(BestResults);
				System.out.println(Surprising);
				BestResults = 0;
			}// for
			in.close();
			out.close();
			fos.close();

	   }
}

import java.io.*;
import java.util.*;

public class B{
	public static void main(String[] args) throws Exception{
		BufferedReader fin = new BufferedReader(new FileReader("B.txt"));
		PrintWriter fout = new PrintWriter(new FileWriter("Bout.txt"));

		String s = fin.readLine();
		int t = Integer.parseInt(s);
		s = fin.readLine();
		for(int i = 0; i < t; i++){
			String[] sp = s.split(" ");

			int n = Integer.parseInt(sp[0]);
			int S = Integer.parseInt(sp[1]);
			int p = Integer.parseInt(sp[2]);

			int[] scores = new int[n];
			for(int j = 3; j < sp.length; j++){
				scores[j-3] = Integer.parseInt(sp[j]);
			}
	
			int[][] mat = new int[31][2];
			mat[0][0] = 0;
			mat[1][0] = 1;
			mat[2][0] = 1;
			mat[3][0] = 1;
			mat[4][0] = 2;
			mat[5][0] = 2;
			mat[6][0] = 2;
			mat[7][0] = 3;
			mat[8][0] = 3;
			mat[9][0] = 3;
			mat[10][0] = 4;
			mat[11][0] = 4;
			mat[12][0] = 4;
			mat[13][0] = 5;
			mat[14][0] = 5;
			mat[15][0] = 5;
			mat[16][0] = 6;
			mat[17][0] = 6;
			mat[18][0] = 6;
			mat[19][0] = 7;
			mat[20][0] = 7;
			mat[21][0] = 7;
			mat[22][0] = 8;
			mat[23][0] = 8;
			mat[24][0] = 8;
			mat[25][0] = 9;
			mat[26][0] = 9;
			mat[27][0] = 9;
			mat[28][0] = 10;
			mat[29][0] = 10;
			mat[30][0] = 10;

			mat[0][1] = 0;
			mat[1][1] = 0;
			mat[2][1] = 1;
			mat[3][1] = 1;
			mat[4][1] = 0;
			mat[5][1] = 1;
			mat[6][1] = 1;
			mat[7][1] = 0;
			mat[8][1] = 1;
			mat[9][1] = 1;
			mat[10][1] = 0;
			mat[11][1] = 1;
			mat[12][1] = 1;
			mat[13][1] = 0;
			mat[14][1] = 1;
			mat[15][1] = 1;
			mat[16][1] = 0;
			mat[17][1] = 1;
			mat[18][1] = 1;
			mat[19][1] = 0;
			mat[20][1] = 1;
			mat[21][1] = 1;
			mat[22][1] = 0;
			mat[23][1] = 1;
			mat[24][1] = 1;
			mat[25][1] = 0;
			mat[26][1] = 1;
			mat[27][1] = 1;
			mat[28][1] = 0;
			mat[29][1] = 0;
			mat[30][1] = 0;

			int numreach = 0;
			int numcould = 0;
			for(int j = 0; j < scores.length; j++){
				if(mat[scores[j]][0] >= p){
					numreach++;
				} else if(mat[scores[j]][0] + 1 >= p && mat[scores[j]][1] == 1){
					numcould++;
				}
			}
			numreach += Math.min(numcould, S);

			fout.println("Case #" + (i + 1) + ": " + numreach);
			fout.flush();
			s = fin.readLine();
		}
	}
}
					
