/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Dancing
 * Jason Bradley Nel
 * 16287398
 */
import java.io.*;

public class Dancing {

    public static void main(String[] args) {

        In input = new In("input.txt");
        int T = Integer.parseInt(input.readLine());

        for (int i = 0; i < T; i++) {
            System.out.printf("Case #%d: ", i + 1);
            int N = input.readInt();
            int s = input.readInt();
            int p = input.readInt();
            int c = 0;//counter for >=p cases
            //System.out.printf("N: %d, S: %d, P: %d, R: ", N, s, p);
            
            for (int j = 0; j < N; j++) {
                
                int score = input.readInt();
                int q = score / 3;
                int m = score % 3;
                //System.out.printf("%2d (%d, %d) ", scores[j], q, m);
                                
                switch (m) {
                    case 0:
                        if (q >= p) {
                            c++;
                        } else if (((q + 1) == p) && (s > 0) && (q != 0)) {
                            c++;
                            s--;
                        }
                        break;
                    case 1:
                        if (q >= p) {
                            c++;
                        } else if ((q + 1) == p) {
                            c++;
                        }
                        break;
                    case 2:
                        if (q >= p) {
                            c++;
                        } else if ((q + 1) == p) {
                            c++;
                        } else if (((q + 2) == p) && (s > 0)) {
                            c++;
                            s--;
                        }
                        break;
                }
            }
            //System.out.printf("Best result of %d or higher: ", p);
            System.out.println(c);
        }


    }
}

import java.util.Scanner;


public class JuanjeProblemaB 
{
	/*
	 * Juan Jesus Gutierrez
	 * Solucion al problema - B
	 */
	public static void main(String[] args)
	{
		//lector de la entrada
		Scanner in = new Scanner(System.in);
		//in.nextLine();
		//numero de frases en Googlerese
		int T = in.nextInt();
		in.nextLine();
		for(int con = 1; con <=T; con++)
		{
			String concurso = in.nextLine();
			int result = tratarConcurso(concurso);
			System.out.format("Case #%d: %d\n", con, result);
		}
	}
	
	public static int tratarConcurso(String concurso)
	{
		int result = 0;
		//System.out.println(concurso);
		String[] datos = concurso.split(" ");
		int N = Integer.parseInt(datos[0]);
		int s = Integer.parseInt(datos[1]);
		int p = Integer.parseInt(datos[2]);
		int[] puntuaciones = new int[N];
		for(int i = 3; i<datos.length; i++)
		{
			puntuaciones[i-3] = Integer.parseInt(datos[i]);
		}
		int[] Pmax = new int[N];
		int[] PmaxS = new int[N];
		for(int i = 0; i<N; i++)
		{
			Pmax[i] = maximoPosible(puntuaciones[i]);
			PmaxS[i] = maximoPosibleConSorpresa(puntuaciones[i]);
		}
		for(int i = 0; i<N; i++)
		{
			if(Pmax[i] >= p)
			{
				result++;
			}
			else
			{
				if(PmaxS[i] >= p && s>0)
				{
					result++;
					s--;
				}
			}
		}
		return result;
	}
	
	public static int maximoPosible(int total)
	{
		if(total == 0) return 0;
		if(total == 30) return 10;
		int d = (int) total / 3;
		int resto = total % 3;
		if(resto == 0) return d;
		return d+1;
	}
	public static int maximoPosibleConSorpresa(int total)
	{
		if(total == 0) return 0;
		if(total == 30) return 10;
		int d = (int) total / 3;
		int resto = total % 3;
		if(resto == 2) return d+2;
		return d+1;
	}
}
