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.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.util.Vector;

class dancing {
	public static void main(String[] args) throws IOException {
		BufferedReader f = new BufferedReader(new FileReader("B-small-attempt0.in"));
		PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(
				"output.txt")));
		StringTokenizer st = new StringTokenizer(f.readLine());
		int cases = Integer.parseInt(st.nextToken());
		for (int k = 1; k < cases; k++) {
			st = new StringTokenizer(f.readLine());
			int memSum = Integer.parseInt(st.nextToken());
			int surprising = Integer.parseInt(st.nextToken());
			int level = Integer.parseInt(st.nextToken());
			int[] scores = new int[memSum];
			for (int i = 0; i < memSum; i++) {
				scores[i] = Integer.parseInt(st.nextToken());
			}
			int max = getMax(memSum, surprising, level, scores);
			out.println("Case #" + k + ": " + max); // output result
		}
		
		st = new StringTokenizer(f.readLine());
		int memSum = Integer.parseInt(st.nextToken());
		int surprising = Integer.parseInt(st.nextToken());
		int level = Integer.parseInt(st.nextToken());
		int[] scores = new int[memSum];
		for (int i = 0; i < memSum; i++) {
			scores[i] = Integer.parseInt(st.nextToken());
		}
		int max = getMax(memSum, surprising, level, scores);
		out.print("Case #" + cases + ": " + max); // output result
		out.close(); // close the output file
		System.exit(0); // don't omit this!
	}

	public static int getMax(int _memSum, int _surprising, int _level,
			int[] _scores) {
		int[] scores = _scores;
		int memSum = _memSum;
		int surprising = _surprising;
		int level = _level;
		int max = 0;
		int certainStart = level * 3 - 2;
		int certainEnd = 30;
		int maybeStart = level * 3 - 4;
		int maybeEnd = level * 3 + 4;
		
		if(certainStart < 0)
		{
			certainStart = level;
		}
		
		if(maybeStart < 0)
		{
			maybeStart = level;
		}
		
		for (int i = 0; i < scores.length; i++) {
			if (scores[i] <= certainEnd && scores[i] >= certainStart) {
				max++;
			} else {
				if (surprising > 0) {
					if (scores[i] <= maybeEnd && scores[i] >= maybeStart) {
						max++;
						surprising--;
					}
				}
			}
		}
		return max;
	}
}