/*
 * 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.PrintStream;
import java.util.Scanner;

public class B {

	public static void main(String[] args) throws Exception {
		System.setOut(new PrintStream("out"));

		Scanner s = new Scanner(System.in);
		int T = s.nextInt();
		for (int t = 1; t <= T; t++) {
			int N = s.nextInt();
			int S = s.nextInt();
			int P = s.nextInt();

			int[][] matrix = { { 0, 0, 0 }, { 0, 0, 1 }, { 0, 1, 0 }, { 0, 1, 1 }, { 0, 0, -1 }, { 0, -1, 0 }, { 0, -1, -1 }, { 1, 0, 0 }, { 1, 0, 1 },
					{ 1, 1, 0 }, { 1, 1, 1 }, { -1, 0, 0 }, { -1, 0, -1 }, { -1, -1, 0 }, { -1, -1, -1 } };

			int[][] matrix2 = { { 1, 1, -1 }, { 1, -1, 0 }, { 1, -1, 1 }, { 1, -1, -1 }, { 1, 0, -1 }, { 1, 1, -1 }, { 1, -1, 0 }, { 1, -1, 1 }, { 1, -1, -1 },
					{ 1, 0, -1 }, { 1, 1, -1 }, { 1, -1, 0 }, { 1, -1, 1 }, { 1, -1, -1 } };

			int max = 0;

			for (int n = 0; n < N; n++) {
				int x = s.nextInt();

				boolean ok = false;
				int m = x / 3;
				for (int i = 0; i < matrix.length; i++) {
					int a = m + matrix[i][0];
					int b = m + matrix[i][1];
					int c = m + matrix[i][2];

					if (a == 7 && b == 6 && c == 9)
						continue;

					if (a + b + c == x && a >= 0 && b >= 0 && c >= 0 && a <= 10 && b <= 10 && c <= 10) {
						if (Math.max(a, Math.max(b, c)) >= P) {
							max++;
							ok = true;
							break;
						}
					}
				}

				if (ok == false) {
					m = x / 3 + 1;
					for (int i = 0; i < matrix.length; i++) {
						int a = m + matrix[i][0];
						int b = m + matrix[i][1];
						int c = m + matrix[i][2];

						if (a == 7 && b == 6 && c == 9)
							continue;

						if (a + b + c == x && a >= 0 && b >= 0 && c >= 0 && a <= 10 && b <= 10 && c <= 10) {
							if (Math.max(a, Math.max(b, c)) >= P) {
								max++;
								ok = true;
								break;
							}
						}
					}
				}

				if (ok == false) {
					m = x / 3 - 1;
					for (int i = 0; i < matrix.length; i++) {
						int a = m + matrix[i][0];
						int b = m + matrix[i][1];
						int c = m + matrix[i][2];

						if (a == 7 && b == 6 && c == 9)
							continue;

						if (a + b + c == x && a >= 0 && b >= 0 && c >= 0 && a <= 10 && b <= 10 && c <= 10) {
							if (Math.max(a, Math.max(b, c)) >= P) {
								max++;
								ok = true;
								break;
							}
						}
					}
				}

				if (ok == false && S > 0) {
					m = x / 3;
					for (int i = 0; i < matrix2.length; i++) {
						int a = m + matrix2[i][0];
						int b = m + matrix2[i][1];
						int c = m + matrix2[i][2];

						if (a == 7 && b == 6 && c == 9)
							continue;

						if (a + b + c == x && a >= 0 && b >= 0 && c >= 0 && a <= 10 && b <= 10 && c <= 10) {
							if (Math.max(a, Math.max(b, c)) >= P) {
								max++;
								S--;
								ok = true;
								break;
							}
						}
					}
				}

				if (ok == false && S > 0) {
					m = x / 3 + 1;
					for (int i = 0; i < matrix2.length; i++) {
						int a = m + matrix2[i][0];
						int b = m + matrix2[i][1];
						int c = m + matrix2[i][2];

						if (a == 7 && b == 6 && c == 9)
							continue;

						if (a + b + c == x && a >= 0 && b >= 0 && c >= 0 && a <= 10 && b <= 10 && c <= 10) {
							if (Math.max(a, Math.max(b, c)) >= P) {
								max++;
								S--;
								ok = true;
								break;
							}
						}
					}
				}
				if (ok == false && S > 0) {
					m = x / 3 - 1;
					for (int i = 0; i < matrix2.length; i++) {
						int a = m + matrix2[i][0];
						int b = m + matrix2[i][1];
						int c = m + matrix2[i][2];

						if (a == 7 && b == 6 && c == 9)
							continue;

						if (a + b + c == x && a >= 0 && b >= 0 && c >= 0 && a <= 10 && b <= 10 && c <= 10) {
							if (Math.max(a, Math.max(b, c)) >= P) {
								max++;
								S--;
								ok = true;
								break;
							}
						}
					}
				}
			}

			System.out.println("Case #" + t + ": " + max);
		}

	}
}
