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 com.first;

public class BDancingWiththeGooglers {

	ReadWriteFileForCodeJam flatFile;

	public BDancingWiththeGooglers() {
		flatFile = new ReadWriteFileForCodeJam();
		initializeFlatFileParameters();
		performSolution();
		finalizeSolutionFileToSend();
	}

	private void performSolution(){
		String[] items;
		int noDancers, noOfSurprises, bestScore;
		int maxGooglers;
		int maxAchieved;
		boolean surprise;
		for(int i=1; i<=Integer.parseInt(flatFile.GetSingleLineFromFile(1)); i++){
			maxGooglers = 0;
			surprise = true;
			items = flatFile.GetSingleLineFromFile(i + 1).split(" ");
			noDancers = Integer.parseInt(items[0]);
			noOfSurprises = Integer.parseInt(items[1]);
			bestScore = Integer.parseInt(items[2]);
			flatFile.setFileContentToWrite("Case #" + i + ":", true, true);
			for(int j=0; j<noDancers; j++){
				if ((noOfSurprises <= 0) && surprise)
					surprise = false;
				maxAchieved = isBestScorePossible(Integer.parseInt(items[j+3]), bestScore);
				switch (maxAchieved){
				case 0: break;
				case 1: maxGooglers++;	break;
				case 2:
					if (surprise){
						maxGooglers++;
						noOfSurprises--;
					}
					break;
				}
			}
			flatFile.setFileContentToWrite(String.valueOf(maxGooglers), true, false);
		}
	}

	private int isBestScorePossible(int total, int least){
		/* return 0 if not possible
		 * 1 if possible without surprise
		 * 2 if possible with surprise
		 */
		
		if (total == 0){
			if (least == 0)
				return 1;
			else
				return 0;
		}
		
		if (total == 1){
			if ((least <= 1))
				return 1;
			else
				return 0;
		}
		
		if (least * 3 - 2 <= total)
			return 1;
		if (least * 3 - 4 <= total)
			return 2;
		return 0;
	}

	private void initializeFlatFileParameters() {
		flatFile.setFileNameForRead("C:\\Users\\i067221\\Downloads\\B-small-attempt0.in");
		flatFile.setFileNameForWrite("C:\\Users\\i067221\\Downloads\\Upload\\B-small-attempt0.txt");
		flatFile.setFileSeperatorForWrite(" ");
		System.out.println("File read, (" + flatFile.ReadFile(false) + ") returned.");
	}

	private void finalizeSolutionFileToSend() {
		System.out.println("Successful write to file performed: " + flatFile.WriteFile(false));
	}

}
