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.*;
import java.util.*;

public class DanceScore
{
	int score;
	boolean surprise = false;
	boolean madeIt = false;
	
	public DanceScore(int score)
	{
		this.score = score;
	}
	
	private void p(String p)
	{
		//System.out.println(p);
	}
	
	public void process(int bestResult)
	{
		int goal = bestResult-2;
		int lastNumber = score-bestResult-bestResult;
		p("score " + score);
		
		p("goal " + bestResult);
		p("lastNumber " + lastNumber);
		if (lastNumber <0)
		{
			madeIt= false;
			surprise = false;
			return;
		}
		
		if (lastNumber >= goal)
			madeIt = true;
		
		int surpriseNumber = bestResult-4;
		if (lastNumber >= surpriseNumber)
			surprise = true;
			
		p("madeIt " + madeIt);
		p("surprise " + surprise);
	}
	
	public boolean surprise()
	{
		return surprise;
	}
	
	public boolean madeIt()
	{
		return madeIt;
	}
	
	
	public static int maxNumber(int[] scores, int numSurprises, int goal)
	{
		int madeItCount = 0;
		int surpriseCount = 0;
		for (int score : scores)
		{
			DanceScore danceScore = new DanceScore(score);
			danceScore.process(goal);
			if (danceScore.madeIt())
				madeItCount++;
			else if (danceScore.surprise())
				surpriseCount++;
		}
		
		if (surpriseCount > numSurprises)
			madeItCount += numSurprises;
		else madeItCount += surpriseCount;
		
		return madeItCount;
	}

	public static void main (String [] args)
	{
		try
		{
			InputStreamReader converter = new InputStreamReader(System.in);
			BufferedReader in = new BufferedReader(converter);

			Integer numCases = Integer.valueOf(in.readLine());
			
			for (int i = 0; i < numCases; i ++)
			{
				String input = in.readLine();
				String[] values = input.split(" ");
				int numPeople = Integer.valueOf(values[0]);
				int numSurprises = Integer.valueOf(values[1]);
				int goal = Integer.valueOf(values[2]);
				int[] scores = new int[numPeople];
				for (int j = 0; j < numPeople ; j++)
				{
					scores[j] = Integer.valueOf(values[3+j]);
				}
				int maxNumber = maxNumber(scores, numSurprises, goal);
				System.out.println("Case #" + (i+1) + ": " + maxNumber);
			}
		} catch (Exception e)
		{
			throw new RuntimeException (e);
		}
	}
}