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

import java.util.Iterator;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.LinkedBlockingQueue;

public class ParallelWorkQueue<I, O> implements Iterable<Future<O>> {

	public interface CallableFactory<I, O> {
		public Callable<O> newInstance(I input);
	}

	private ExecutorService threadPool;
	private LinkedBlockingQueue<Future<O>> workQueue;
	private Future<O> poisonPill = null;

	public ParallelWorkQueue(final int numThreads, final Iterable<I> inputs, final CallableFactory<I, O> callableFactory) {
		threadPool = Executors.newFixedThreadPool(numThreads);

		// Keep a max of (100x the number of threads) items in the work queue at a time 
		workQueue = new LinkedBlockingQueue<>(numThreads * 100);

		// Create work-producer thread
		new Thread() {
			public void run() {
				try {
					for (final I input : inputs)
						workQueue.put(threadPool.submit(callableFactory.newInstance(input)));

					// poisonPill was null until now, and null can never be put in the queue, so
					// the barrier can't be triggered. Now set poisonPill to another value that it
					// can only attain once, a NOP work unit.
					workQueue.put(poisonPill = threadPool.submit(new Callable<O>() {
						@Override
						public O call() throws Exception {
							return null;
						}
					}));

					// Shut down threads after last callable invoked
					threadPool.shutdown();

				} catch (InterruptedException e) {
					throw new RuntimeException(e);
				}
			};
		}.start();

	}

	@Override
	public Iterator<Future<O>> iterator() {
		return new Iterator<Future<O>>() {
			Future<O> next = null;
			boolean nextConsumed = true;

			@Override
			public boolean hasNext() {
				if (nextConsumed) {
					try {
						next = workQueue.take();
					} catch (InterruptedException e) {
						throw new RuntimeException(e);
					}
					nextConsumed = false;
				}
				// Check for poison pill
				if (next == poisonPill) {
					try {
						// Get result of poison pill Future so thread exits
						next.get();
					} catch (Exception e) {
						throw new RuntimeException(e);
					}
					return false; // at end
				} else {
					return true;
				}
			}

			@Override
			public Future<O> next() {
				if (nextConsumed)
					throw new RuntimeException("Can't call next() twice without calling hasNext()");
				nextConsumed = true;
				return next;
			}

			@Override
			public void remove() {
				throw new UnsupportedOperationException();
			}
		};
	}

	/**
	 * Return an Iterable<Integer> that iterates from 0 to n-1 inclusive. Can be
	 * passed into the "inputs" parameter of ParallelWorkQueue.
	 */
	public static Iterable<Integer> makeIntRangeIterable(final int n) {
		return new Iterable<Integer>() {
			private final int max = n;

			@Override
			public Iterator<Integer> iterator() {
				return new Iterator<Integer>() {
					int num = 0;

					@Override
					public boolean hasNext() {
						return num < max;
					}

					@Override
					public Integer next() {
						return num++;
					}

					@Override
					public void remove() {
						throw new UnsupportedOperationException();
					}
				};
			}
		};
	}
}

