/*
 * 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.BufferedReader;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;


public class source {
	
	public static void main(String args[ ]) throws IOException {		
		
		FileInputStream fstream = new FileInputStream("text.txt");
		DataInputStream in = new DataInputStream(fstream);
		  BufferedReader br = new BufferedReader(new InputStreamReader(in));
		  String strLine;
		  int c = 1;
		  int f = 0;
		  int sur = 0;
		  boolean b = false;
		  
		  br.readLine();
		  while ((strLine = br.readLine()) != null)   {
			String[] array = strLine.split(" ");
			int[] array2 = new int[array.length];
			
			for (int i = 0; i < array.length; i++) {
				array2[i] = Integer.parseInt(array[i]);
			}
			
			for (int s = 3; s<array2[0]+3; s++) {
				
				for (int  i = 0; i <= 10 && !b; i++) {
					for (int j = 0; j <= 10 && !b; j++) {
						for (int k = 0; k <= 10 && !b; k++) {
							
							if (i+j+k == array2[s]
							      && ((i >= array2[2]) || (j >= array2[2]) || (k >= array2[2]))
							      && ((i-j >= 0) && (i-j <= 1))
							      && ((i-k >= 0) && (i-k <= 1))
							      && ((k-k >= 0) && (j-k <= 1))) {
								b = true;
								//System.out.println(i + " " + j + " " + k);
							}
						}
					}
				}
				
				if (b) {
					f++;
					b=false;
				}
				else {
					b = false;
					for (int  i = 0; i <= 10 && !b; i++) {
						for (int j = 0; j <= 10 && !b; j++) {
							for (int k = 0; k <= 10 && !b; k++) {
								
								if (i+j+k == array2[s]
								      && ((i >= array2[2]) || (j >= array2[2]) || (k >= array2[2]))
								      && ((i-j >= 0) && (i-j <= 2))
								      && ((i-k >= 0) && (i-k <= 2))
								      && ((k-k >= 0) && (j-k <= 2))) {
									b = true;
									//System.out.println(i + " " + j + " " + k);
								}
							}
						}
					}
					if (b) {
						sur++;
						b=false;
					}
				}
			}
			
			if (sur >= array2[1]) {
				System.out.println("Case #" + c + ": " + (f + array2[1]));
			}
			else {
				System.out.println("Case #" + c + ": " + (f + sur));
			}
			f = 0;
			sur = 0;
			c++;
		  }
	}
}
