import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;


public class B {
	static int[][] memo;
	static int[] nums;
	static int p;
	public static void main(String[] args)throws IOException
	{
		Scanner br=new Scanner(new File("B-small-attempt0.in"));
		PrintWriter out=new PrintWriter(new File("b.out"));
		int cases=br.nextInt();
		for(int c=1;c<=cases;c++)
		{
			int n=br.nextInt(),s=br.nextInt();
			p=br.nextInt();
			nums=new int[n];
			for(int i=0;i<n;i++)
				nums[i]=br.nextInt();
			memo=new int[n][s+1];
			for(int[] a:memo)
				Arrays.fill(a,-1);
			out.printf("Case #%d: %d\n",c,go(0,s));
		}
		out.close();
	}
	public static int go(int index,int s)
	{
		if(index>=nums.length)
			return 0;
		if(memo[index][s]!=-1)
			return memo[index][s];
		int best=0;
		for(int i=0;i<=10;i++)
		{
			int max=i;
			for(int j=0;j<=10;j++)
			{	
				if(Math.abs(i-j)>2)
					continue;
				max=Math.max(i,j);
				thisone:
				for(int k=0;k<=10;k++)
				{
					int ret=0;
					if(Math.abs(i-k)>2||Math.abs(j-k)>2)
						continue;
					max=Math.max(max,k);
					int count=0;
					if(Math.abs(i-k)==2)
						count++;
					if(Math.abs(i-j)==2)
						count++;
					if(Math.abs(j-k)==2)
						count++;
					if(i+j+k==nums[index])
					{
						boolean surp=(count>=1);
						if(surp&&s>0)
						{
							if(max>=p)
								ret++;
							ret+=go(index+1,s-1);
						}
						else if(!surp)
						{
							if(max>=p)
								ret++;
							ret+=go(index+1,s);
						}
						best=Math.max(best,ret);
					}
					else if(i+j+k>nums[index])
						break thisone;
				}
			}
		}
		return memo[index][s]=best;
	}
}

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

public class Googlers {

	public static void main(String[] args) throws FileNotFoundException {
		new Googlers().doProcessing(new File("D:\\codejam\\B\\small.txt"));
	}

	public void doProcessing(File inputFile) throws FileNotFoundException {
		Scanner scanner = new Scanner(inputFile).useDelimiter("\n");
		if (scanner != null) {
			int totalCases = Integer.parseInt(scanner.next().trim());
			int k = 1 ;
			if (totalCases > 0) {
				while (scanner.hasNext()) {
					String[] rowValues = scanner.next().trim().split(" ");

					int totalGooglers = Integer.parseInt(rowValues[0]);
					// System.out.println("Total Googlers : " + totalGooglers);
					int totalSuprisingCases = Integer.parseInt(rowValues[1]);
					// System.out.println("Total Surprising Cases : " +
					// totalSuprisingCases);

					int averageScore = Integer.parseInt(rowValues[2]);
					// System.out.println("Total Success Cases : " +
					// averageScore);
					// System.out.println("Total Length : " + rowValues.length);

					int[] totalMarks = new int[totalGooglers];
					int j = 0;
					for (int i = 3; i < rowValues.length; i++) {
						totalMarks[j] = Integer.parseInt(rowValues[i].trim());
						// System.out.println("Value Put : " + totalMarks[j]);
						j++;
					}
					int successCase = getSuccessCase(totalGooglers,
							averageScore, totalSuprisingCases, totalMarks);
					System.out.println("Case #" + k++ + ": " + successCase);
				}

			}
		}
		scanner.close();
	}

	public boolean doNormalCase(int totalScore, int averageScore) {
		boolean success = false;
		int X3value = averageScore * 3;
		if (totalScore >= X3value) {
			success = true;
		} else if ((totalScore >= X3value - 1) || (totalScore >= X3value + 1)) {
			success = true;
		} else if ((totalScore >= X3value - 2) || (totalScore >= X3value + 2)) {
			success = true;
		} else {
			success = false;
		}
		return success;
	}

	public boolean doSurprisingCase(int totalScore, int averageScore) {
		boolean success = false;
		int X3value = averageScore * 3;
		// System.out.println("Total Score : " + totalScore);
		// System.out.println("Average Score : " + X3value);
		if (((totalScore >= X3value - 3) || (totalScore >= X3value + 3))
				&& totalScore > averageScore) {
			success = true;
		} else if (((totalScore >= X3value - 4) || (totalScore >= X3value + 4))
				&& totalScore > averageScore) {
			success = true;
		} else {
			success = false;
		}
		return success;
	}

	public int getSuccessCase(int totalCses, int averageScore,
			int surprisingCase, int[] caseValues) {
		int totalSuccess = 0;
		for (int i = 0; i < totalCses; i++) {
			// System.out.println("----------------------Value Put : " +
			// totalCses);
			boolean normalCaseSuccess = doNormalCase(caseValues[i],
					averageScore);
			if (!normalCaseSuccess) {
				if (surprisingCase > 0) {
					boolean surprisingCaseSuccess = doSurprisingCase(
							caseValues[i], averageScore);
					if (surprisingCaseSuccess) {
						// System.out.println("Surprising Success..." +
						// caseValues[i]);
						totalSuccess++;
						surprisingCase--;
					}
				}
			} else {
				totalSuccess++;
			}
		}
		return totalSuccess;
	}

}
