package code12.qualification;

import java.io.File;
import java.io.FileWriter;
import java.util.Scanner;

public class B {
	public static String solve(int N, int S, int p, int[] t) {
		
		// 3a 		-> (a, a, a), *(a - 1, a, a + 1)
		// 3a + 1	-> (a, a, a + 1), *(a - 1, a + 1, a + 1)
		// 3a + 2	-> (a, a + 1, a + 1), *(a, a, a + 2)
		
		int numPNoS = 0;
		int numPWithS = 0;
		
		for (int i = 0; i < N; i++) {
			int a = (int)Math.floor(t[i] / 3);
			int r = t[i] % 3;
			
			switch (r) {
			case 0:
				if (a >= p) {
					numPNoS++;
				} else if (a + 1 >= p && a - 1 >= 0) {
					numPWithS++;
				}
				break;
			case 1:
				if (a >= p || a + 1 >= p) {
					numPNoS++;
				}
				break;
			case 2:
				if (a >= p || a + 1 >= p) {
					numPNoS++;
				} else if (a + 2 >= p) {
					numPWithS++;
				}
				break;
			}
		}
		
		return "" + (numPNoS + Math.min(S, numPWithS));
	}

	public static void main(String[] args) throws Exception {
		// file name
		//String fileName = "Sample";
		//String fileName = "B-small";
		String fileName = "B-large";
		
		// file variable
		File inputFile = new File(fileName + ".in");
		File outputFile = new File(fileName + ".out");
		Scanner scanner = new Scanner(inputFile);
		FileWriter writer = new FileWriter(outputFile);

		// problem variable
		int totalCase;
		int N, S, p;
		int[] t;

		// get total case
		totalCase = scanner.nextInt();

		for (int caseIndex = 1; caseIndex <= totalCase; caseIndex++) {
			// get input
			N = scanner.nextInt();
			S = scanner.nextInt();
			p = scanner.nextInt();
			t = new int[N];
			
			for (int i = 0; i < N; i++) {
				t[i] = scanner.nextInt();
			}
			
			String output = "Case #" + caseIndex + ": " + solve(N, S, p, t);
			System.out.println(output);
			writer.write(output + "\n");
		}
		scanner.close();
		writer.close();
	}
}

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class B {
	static int[][] dp;
	static int[] sum;
	static int p;

	public static int abs(int a) {
		return (a < 0) ? -a : a;
	}

	public static int go(int i, int j) {
		if (j < 0)
			return -1000;
		if (i == sum.length) {
			if (j != 0)
				return -1000;
			else
				return 0;
		}

		else if (dp[i][j] != -1)
			return dp[i][j];
		else {
			int max = 0;
			for (int a = 0; a <= 10 && a <= sum[i]; a++)
				for (int b = a; b <= a + 2 && b <= 10 && a + b <= sum[i]; b++)
					for (int c = a; c <= a + 2 && c <= 10
							&& a + b + c <= sum[i]; c++) {
						if (a + b + c == sum[i]) {
							int cool = 0;
							int awesome = 0;
							if (b - a == 2 || c - a == 2)
								cool = 1;
							if (a >= p || b >= p || c >= p)
								awesome = 1;
							max = Math.max(max, awesome + go(i + 1, j - cool));
						}
					}
			return dp[i][j] = max;
		}
	}

	public static void main(String[] args) throws Exception {
		BufferedReader in = new BufferedReader(new InputStreamReader(
				new FileInputStream("B.in")));
		PrintWriter out = new PrintWriter("B.out");
		int tc = Integer.parseInt(in.readLine());
		for (int cc = 1; cc <= tc; cc++) {
			StringTokenizer strtok = new StringTokenizer(in.readLine(), " ");
			int n = Integer.parseInt(strtok.nextToken());
			int s = Integer.parseInt(strtok.nextToken());
			p = Integer.parseInt(strtok.nextToken());
			dp = new int[n][s + 1];
			for (int[] a : dp)
				Arrays.fill(a, -1);
			sum = new int[n];
			for (int i = 0; i < n; i++)
				sum[i] = Integer.parseInt(strtok.nextToken());
			out.printf("Case #%d: %d\n", cc, go(0, s));
		}
		out.close();
		in.close();
	}
}
