/*
 * 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.*;
public class googleJam2 {

	/**
	 * @param args
	 */
	public static void main(String[] args) throws Exception {
		// TODO Auto-generated method stub
		BufferedReader reader = null;
		PrintWriter writer = null;
		try{
			reader = new BufferedReader(new FileReader("B-small-attempt1.in"));
			int numInputs = Integer.parseInt(reader.readLine());
			writer = new PrintWriter(new BufferedWriter(new FileWriter("B-small-attempt1.out")));
			for(int i = 0; i < numInputs; i++)
			{
				System.out.println(i);
				String temp = reader.readLine();
				System.out.println(temp);
				int index = temp.indexOf(" ");
				int numGooglers = Integer.parseInt(temp.substring(0, index));
				temp = temp.substring(index+1);
				index = temp.indexOf(" ");
				System.out.println(temp);
				int numSurprising = Integer.parseInt(temp.substring(0,index));
				temp = temp.substring(index+1);
				index = temp.indexOf(" ");
				int p = Integer.parseInt(temp.substring(0,index));
				temp = temp.substring(index+1);
				int withoutSurprise = 0;
				int withSurprise = 0;
				for(int k = 0; k < numGooglers-1; k++)
				{
					index = temp.indexOf(" ");
					int totalScore = Integer.parseInt(temp.substring(0, index));
					temp = temp.substring(index+1);
					if(totalScore >= 3*p -2)
						withoutSurprise++;
					else if(totalScore >= 3*p-4 && totalScore >= p)
						withSurprise++;
				}
				int totalScore = Integer.parseInt(temp);
				if(totalScore >= 3*p -2)
					withoutSurprise++;
				else if(totalScore >= 3*p-4 &&totalScore >= p)
					withSurprise++;
				int numWinners;
				if(withSurprise >= numSurprising)
					numWinners = numSurprising + withoutSurprise;
				else
					numWinners = withSurprise + withoutSurprise;
				writer.print("Case #" + (i+1) + ": " + numWinners + "\n");
				
				
			}
			writer.close();
		}
		catch(Exception e)
		{
			throw(e);
		}
	}

}
