/**
 * Created by IntelliJ IDEA.
 * User: Administrator
 * Date: 3/3/12
 * Time: 11:00 AM
 * To change this template use File | Settings | File Templates.
 */

import SRMLib.MathLibrary;
import SRMLib.TestSRMLib;
import com.sun.org.apache.bcel.internal.generic.F2D;

import java.io.*;
import java.util.*;
import java.util.zip.Inflater;

public class SRM {
    public static void main(String[] args) throws IOException {
        //TestSRMLib.run();
        codeJam1.main();

        return;
    }
}
class codeJam1 {
    public static void main() throws IOException {
        String inputPath = "E:\\input.txt";
        String outputPath = "E:\\output.txt";
        BufferedReader input = new BufferedReader(new FileReader(inputPath));
        BufferedWriter output = new BufferedWriter(new FileWriter(outputPath));

        String line;
        line = input.readLine();
        int T = Integer.parseInt(line);
        for (int i = 1; i <= T; ++i) {
            line = input.readLine();
            String[] words = line.split(" ");
            int N = Integer.parseInt(words[0]);
            int S = Integer.parseInt(words[1]);
            int p = Integer.parseInt(words[2]);
            int n = 0;
            int res = 0;

            for (int j = 3; j < words.length; ++j) {
                if (p == 0) {
                    res++;
                    continue;
                }

                int t = Integer.parseInt(words[j]);
                if (p == 1) {
                    if (t > 0)
                        res++;
                    continue;
                }
                if (t >= 3 * p - 2)
                    res++;
                else if (t >= 3 * p - 4)
                    n++;
            }

            res += Math.min(n, S);
            output.write("Case #" + i + ": " + res);
            output.newLine();
        }

        input.close();
        output.close();
    }
}

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

public class DancingWithGooglers {
	final static int[] _3n_2 = new int[] { 2, 5, 8, 11, 14, 17, 20, 23, 26, 29 };
	final static int[] _3n_4 = new int[] { 4, 7, 10, 13, 16, 19, 22, 25, 28 };

	// return -1 if cannot be written as surprising form
	public static int surprisingN(int n) {
		if (n == 0)
			return -999;
		for (int i : _3n_2)
			if (i == n)
				return (n - 2) / 3;
		if (n % 3 == 0) // 3n+3
			return (n-3) / 3;
		return (n - 4) / 3;
	}

	public static int nonSurprisingN(int n) {
		if ((n - 1) % 3 == 0)
			return (n - 1) / 3;
		if ((n - 2) % 3 == 0)
			return (n - 2) / 3;
		return n / 3;
	}

	public static int enact(int S, int p, int[] scores) {
		if (S == 0) {
			// find best score
			// return
			int tmp = 0;
			for (int i : scores) {
				int n = nonSurprisingN(i);
				if (p <= n)
					tmp++;
				else if (p == n + 1) {
					if (i % 3 != 0)
						tmp++;
				}
			}
			return tmp;
		}

		int max = 0;
		int N = 0; // number of googlers have a best score at least p
		// setting one valid googler to be surprising case
		for (int i = 0; i < scores.length; i++) {
			int tmp = scores[i];
			scores[i] = -999;
			N = enact(S - 1, p, scores);
			scores[i] = tmp;

			if (p <= surprisingN(scores[i]) + 2)
				N++;

			if (N > max)
				max = N;
		}
		return max;
	}

	public static void main(String[] args) throws FileNotFoundException {
		Scanner sc = new Scanner(new File("B-small-attempt2.in"));
		int T = sc.nextInt();
		for (int i = 0; i < T; i++) {
			int n = sc.nextInt();
			int S = sc.nextInt();
			int p = sc.nextInt();
			int[] scores = new int[n];
			for (int j = 0; j < n; j++) {
				scores[j] = sc.nextInt();
			}

			int result = enact(S, p, scores);
			System.out.format("Case #%d: %d%n", i + 1, result);
		}
	}
}
