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

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;

public class DancingWithTheGooglers {

	
	public static void main(String[] args) throws IOException {
		

		BufferedReader br=new BufferedReader(new FileReader(new File("./dancingwiththegooglers/b-small-attempt1.in")));
		BufferedWriter bw=new BufferedWriter(new FileWriter(new File("./dancingwiththegooglers/small1.out")));
		
		int numberOfCase=Integer.parseInt(br.readLine());
		
		StringBuilder out=new StringBuilder();
		
		for(int i=1;i<=numberOfCase;i++){
			int count=0;
			out.append("Case #"+i+": ");
			
			String[]input=br.readLine().split(" ");
			
			int surprising=Integer.parseInt(input[1]);
			int goal=Integer.parseInt(input[2]);
			int googlers=Integer.parseInt(input[0]);
			for(int j=3;j<3+googlers;j++){
				
				int result=check(Integer.parseInt(input[j]),goal,surprising);
				if(result==0){
					count++;
					surprising--;
				}
				if(result==1)
					count++;
				
					
				
			}
			
			
			
			out.append(count);
			if(i<numberOfCase)
				out.append("\n");			
			
			
		}
		bw.write(out.toString());
		br.close();
		bw.close();
		

	}
	
	/*
	 * return  1 - possible to achieve goal and is not surprising
	 *         0 - possible to achieve goal and is surprising
	 *         -1 - impossible to achieve goal
	 */
	public static int check(int totalScore,int goal,int surprising){
		
		if(totalScore<goal)
			return -1;
		
		int r=totalScore%3;
		int max=-1;
		if(r==0)
			max=totalScore/3;
		if(r==1)
			max=(int)Math.ceil(totalScore/3.0);
		if(r==2)
			max=(int)Math.ceil(totalScore/3.0);
		
		if(max<goal)
			if(surprising==0)
				return -1;
			else{
				if(totalScore>=goal+(goal-2)+(goal-2))
					return 0;
				else
					return -1;
			}
		else
			return 1;
		
	}

}
