/*
 * 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.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.LineNumberReader;
import java.io.PrintWriter;


public class bsp2 {

	/**
	 * @param args
	 * @throws IOException 
	 * @throws NumberFormatException 
	 */
	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO Auto-generated method stub
		String inFile = "B-small-attempt0.in";
		String outFile = inFile + ".out";
		
		LineNumberReader lin = new LineNumberReader(new InputStreamReader(new FileInputStream(inFile)));
		PrintWriter out = new PrintWriter(new File(outFile));
		int NCASE = Integer.parseInt(lin.readLine());
		String line="";
		int erg=0;
		for(int CASE = 1; CASE <= NCASE; CASE++) {
			String [] ch=lin.readLine().split(" ");
			int googlers=Integer.parseInt(ch[0]);
			int sTriplets=Integer.parseInt(ch[1]);
			int bResult=Integer.parseInt(ch[2]);
			//System.out.println("Case #"+CASE);
			//System.out.println(googlers);
			//System.out.println(sTriplets);
			//System.out.println(bResult);
			for(int SCORE=3;SCORE<ch.length;SCORE++){
				//System.out.print(ch[SCORE]);
				int base=Integer.parseInt(ch[SCORE])/3;
				switch(Integer.parseInt(ch[SCORE])%3){
					case 0:
						if(base >=bResult) erg++;
						else{
							if(sTriplets>0 && base>0 && base+1 >=bResult){
								erg++;
								sTriplets--;
							}
						}
						break;
					case 1:
						if(base>=bResult||base+1>=bResult) erg++;
						else{
							if(sTriplets>0 && base>0 && base+1 >=bResult){
								erg++;
								sTriplets--;
							}
						}
						break;
					case 2:
						if(base+1>=bResult||base>=bResult) erg++;
						else{
							if(sTriplets>0 && base>0 && base+2 >=bResult){
								erg++;
								sTriplets--;
							}
						}
						break;
				}
			}
			out.println("Case #" + CASE + ": "+erg);
			erg=0;
		}
		
		lin.close();
		out.close();
	}

}
