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

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 java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

public class FileHelper {

	private String path;
	private int totalSize;
	private List<String> inputList;
	private List<String> outputList;
	
	public FileHelper(String path) {
		this.path = path;
		this.inputList = readFile(path);
		this.totalSize = Integer.parseInt(inputList.get(0));
	}
	
	public String getPath() {
		return path;
	}

	public void setPath(String path) {
		this.path = path;
	}

	public int getTotalSize() {
		return totalSize;
	}

	public void setTotalSize(int totalSize) {
		this.totalSize = totalSize;
	}

	public List<String> getInputList() {
		return inputList;
	}

	public void setInputList(List<String> inputList) {
		this.inputList = inputList;
	}

	public List<String> getOutputList() {
		return outputList;
	}

	public void setOutputList(List<String> outputList) {
		this.outputList = outputList;
	}

	public static List<String> readFile(String filepath) {
        List<String> rstList = new ArrayList<String>();

        try {
                FileInputStream fstream = new FileInputStream(filepath);
                // Get the object of DataInputStream
                DataInputStream in = new DataInputStream(fstream);
                BufferedReader br = new BufferedReader(new InputStreamReader(in));

                String strLine;

                // Read File Line By Line
                while ((strLine = br.readLine()) != null) {
                        rstList.add(strLine);
                }

                // Close the input stream
                in.close();
        } catch (Exception e) {// Catch exception if any
                System.err.println("Error: " + e.getMessage());
        }

        return rstList;
	}
	
	 public static void writeFile(String filepath,
             List<String> resList) {
     try {

             FileWriter fstream = new FileWriter(filepath);
             BufferedWriter out = new BufferedWriter(fstream);
             for(int i = 0 ; i< resList.size();++i){
                     out.write(resList.get(i));
                     System.out.println(resList.get(i));
                     if( i != resList.size()  - 1)
                    	 out.newLine();
             }
             // Close the output stream
             out.close();

     } catch (Exception e) {// Catch exception if any
             System.err.println("Error: " + e.getMessage());
     }

}



	public int getInputTotalSize() {

		
		return 0;
	}

	public void init(String[] inputStr) {
		for(int i = 1; i< this.inputList.size(); ++i	){
			inputStr[i - 1] = inputList.get(i);
		}
	}


}
