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.FileInputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

import static java.lang.Math.*;


public class Solution implements Runnable {

	public static void main(String[] args) {
		new Thread(new Solution()).start();
	}
	
	@Override
	public void run() {
		try {
			solve();
		} catch (Exception e) {
			e.printStackTrace();
			throw new RuntimeException("Laja in solution");
		}
	}
	
	private String next() throws IOException {
		while (tok == null || !tok.hasMoreTokens()) {
			tok = new StringTokenizer(cin.readLine());
		}
		
		return tok.nextToken();
	}
	
	private int nextInt() throws IOException {
		return Integer.parseInt(next());
	}
	
	private long nextLong() throws IOException {
		return Long.parseLong(next());
	}
	
	BufferedReader cin;
	StringTokenizer tok;
	PrintWriter cout;
	
	public void solve() throws Exception {
		//cin = new BufferedReader(new FileReader("input.txt"));
		cin = new BufferedReader(new FileReader("B-small-attempt0.in "));
		cout = new PrintWriter("output.txt");
		//cout = new PrintWriter("");
		
		int testcases = nextInt();
		for (int testcase = 0; testcase < testcases; ++testcase) {
			int n = nextInt();
			int s = nextInt();
			int p = nextInt();
			
			int[] a = new int[n];
			for (int i = 0; i < n; ++i) {
				a[i] = nextInt();
			}
			
			int[][] d = new int[n + 1][s + 1];
			for (int i = 0; i < n + 1; ++i) {
				Arrays.fill(d[i], -10000);
			}
			
			d[0][s] = 0;
			
			for (int i = 0; i < n; ++i) {
				for (int j = 0; j <= s; ++j) {
					int mod = a[i] % 3;
					int del = a[i] / 3;
					
					// non surprising
					if (mod == 0) {
						d[i + 1][j] = max(d[i + 1][j], d[i][j] + toInt(del >= p));
					} else {
						d[i + 1][j] = max(d[i + 1][j], d[i][j] + toInt(del + 1 >= p));
					}
					
					// surprising
					if (j > 0 && 2 <= a[i] && a[i] <= 28) {
						if (mod == 2) {
							d[i + 1][j - 1] = max(d[i + 1][j - 1], d[i][j] + toInt(del + 2 >= p));
						} else {
							d[i + 1][j - 1] = max(d[i + 1][j - 1], d[i][j] + toInt(del + 1 >= p));
						}
					}
				}
			}
			
			cout.println("Case #" + (testcase + 1) + ": " + d[n][0]);
		}
		
		cout.close();
	}

	private int toInt(boolean b) {
		return b ? 1 : 0;
	}
}
