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;
	}
}

package small;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.InputStreamReader;

import javax.swing.plaf.basic.BasicInternalFrameTitlePane.MaximizeAction;

public class DancingGooglers {
	private static int noOfCases;
	private static int[] noOfGooglers;
	private static int[] noOfSurprisingTriplets;
	private static int[] bestResult;
	private static int[][] scores;
	private static String[] result;

	public static void main(String[] args) {

		readInputFile();
		result = new String[noOfCases];

		for (int i = 0; i < noOfCases; i++) {
			int totalSum = 0;
			int surprisingCount = 0;
			for (int j = 0; j < noOfGooglers[i]; j++) {
				// System.out.print(" "+scores[i][j]);
				if (scores[i][j] >= bestResult[i]) {
					if ((scores[i][j] - bestResult[i]) / 2 >= bestResult[i] - 2) {
						totalSum++;
						if ((scores[i][j] - bestResult[i]) / 2 == bestResult[i] - 2) {
							surprisingCount++;
						}
					}
				}

			}

			if (surprisingCount > noOfSurprisingTriplets[i]) {
				totalSum = totalSum
						- (surprisingCount - noOfSurprisingTriplets[i]);
			}
			System.out.println();
			System.out.println("Case #" + (i + 1) + ": " + totalSum);
			result[i] = "Case #" + (i + 1) + ": " + totalSum;

		}

		writeToFile(result);

	}

	private static void readInputFile() {

		try {
			FileInputStream fstream = new FileInputStream("B-small-attempt0.in");
			DataInputStream in = new DataInputStream(fstream);
			BufferedReader br = new BufferedReader(new InputStreamReader(in));

			noOfCases = Integer.parseInt(br.readLine());
			String strLine;
			scores = new int[noOfCases][];
			noOfGooglers = new int[noOfCases];
			noOfSurprisingTriplets = new int[noOfCases];
			bestResult = new int[noOfCases];
			for (int i = 0; i < noOfCases; i++) {
				strLine = br.readLine();
				String[] temp = strLine.split(" ");
				noOfGooglers[i] = Integer.parseInt(temp[0]);
				noOfSurprisingTriplets[i] = Integer.parseInt(temp[1]);
				bestResult[i] = Integer.parseInt(temp[2]);
				scores[i] = new int[noOfGooglers[i]];

				// System.out.println("No of Googlers: "+noOfGooglers);
				// System.out.println("No of surp trip: "+noOfSurprisingTriplets);
				// System.out.println("Best Result: "+bestResult);

				for (int j = 0; j < noOfGooglers[i]; j++) {
					scores[i][j] = Integer.parseInt(temp[3 + j]);
					System.out.println(scores[i][j]);
				}

			}

			in.close();
		} catch (Exception e) {
			e.printStackTrace();
			System.err.println("Error: " + e.getMessage());
		}
	}

	public static void writeToFile(String args[]) {
		try {
			FileWriter fstream = new FileWriter("B-small-attempt0.out");
			BufferedWriter out = new BufferedWriter(fstream);
			for (int i = 0; i < args.length; i++) {
				out.write(args[i]);
				if (i != args.length - 1)
					out.newLine();
			}
			out.close();
		} catch (Exception e) {
			System.err.println("Error: " + e.getMessage());
		}
	}

}
