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.FileReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

import static java.lang.Math.*;


public class Solution implements Runnable {

	public static void main(String[] args) {
		new Thread(new Solution()).start();
	}
	
	@Override
	public void run() {
		try {
			solve();
		} catch (Exception e) {
			e.printStackTrace();
			throw new RuntimeException("Laja in solution");
		}
	}
	
	private String next() throws IOException {
		while (tok == null || !tok.hasMoreTokens()) {
			tok = new StringTokenizer(cin.readLine());
		}
		
		return tok.nextToken();
	}
	
	private int nextInt() throws IOException {
		return Integer.parseInt(next());
	}
	
	private long nextLong() throws IOException {
		return Long.parseLong(next());
	}
	
	BufferedReader cin;
	StringTokenizer tok;
	PrintWriter cout;
	
	public void solve() throws Exception {
		//cin = new BufferedReader(new FileReader("input.txt"));
		cin = new BufferedReader(new FileReader("B-large.in "));
		cout = new PrintWriter("output.txt");
		//cout = new PrintWriter("");
		
		int testcases = nextInt();
		for (int testcase = 0; testcase < testcases; ++testcase) {
			int n = nextInt();
			int s = nextInt();
			int p = nextInt();
			
			int[] a = new int[n];
			for (int i = 0; i < n; ++i) {
				a[i] = nextInt();
			}
			
			int[][] d = new int[n + 1][s + 1];
			for (int i = 0; i < n + 1; ++i) {
				Arrays.fill(d[i], -10000);
			}
			
			d[0][s] = 0;
			
			for (int i = 0; i < n; ++i) {
				for (int j = 0; j <= s; ++j) {
					int mod = a[i] % 3;
					int del = a[i] / 3;
					
					// non surprising
					if (mod == 0) {
						d[i + 1][j] = max(d[i + 1][j], d[i][j] + toInt(del >= p));
					} else {
						d[i + 1][j] = max(d[i + 1][j], d[i][j] + toInt(del + 1 >= p));
					}
					
					// surprising
					if (j > 0 && 2 <= a[i] && a[i] <= 28) {
						if (mod == 2) {
							d[i + 1][j - 1] = max(d[i + 1][j - 1], d[i][j] + toInt(del + 2 >= p));
						} else {
							d[i + 1][j - 1] = max(d[i + 1][j - 1], d[i][j] + toInt(del + 1 >= p));
						}
					}
				}
			}
			
			cout.println("Case #" + (testcase + 1) + ": " + d[n][0]);
		}
		
		cout.close();
	}

	private int toInt(boolean b) {
		return b ? 1 : 0;
	}
}
