/*
 * 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 dancing {
	
	static int N;
	static int S;
	static int p;
	static int[] t;
	
	public static boolean normal(int tot){
		int max = tot%3==0?tot/3:tot/3+1;
		return max>=p;
	}
	
	public static boolean surprising(int tot){
		int max = tot==0?0:(tot+1)/3+1;
		
		return max>=p;
	}
	
	
	public static int solve(){
		int DB=0;
		int SDB = S;
		for(int i=0; i<N; i++){
			if(normal(t[i])) DB++;
			else if(SDB > 0 && surprising(t[i])){
				DB++; SDB--;
			}
		}
		
		return DB;
	}
	
	public static void main (String args[]) throws IOException{
		
		
		BufferedReader be = new BufferedReader(new FileReader("B-small.in"));
		int T = Integer.parseInt(be.readLine());
		for(int i=1; i<=T; i++){
			String s = be.readLine();
			N = Integer.parseInt(s.split(" ")[0]);
			S = Integer.parseInt(s.split(" ")[1]);
			p = Integer.parseInt(s.split(" ")[2]);
			t = new int[N];
			for(int j = 0; j < N; j++)
				t[j] = Integer.parseInt(s.split(" ")[j+3]);
			System.out.println("Case #"+i+": "+solve());
		}
		be.close();
	}
}

