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

import java.io.*;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.StringTokenizer;

public class B {
    static String str = "C:\\carl\\fileB.txt";
    static String text = "";

    static int N, S, P,T;
    static int[][] list;


    public static void main(String[] args) {

        try {
            int caser = 1;
            int count = 0;
            File file = new File(str);
            BufferedReader br = new BufferedReader(new FileReader(file));
            PrintWriter outer = new PrintWriter(new FileWriter("C:\\carl\\outB.txt"));


            while((text = br.readLine()) != null) {
                StringTokenizer st = new StringTokenizer(text);

                if(count == 0) {
                    T = Integer.parseInt(st.nextToken());
                    System.out.println(T);
                    count++;
                } else  {
                    /* each subsequent line */
                    N = Integer.parseInt(st.nextToken());
                    list = new int[N][3];
                    S = Integer.parseInt(st.nextToken());
                    P = Integer.parseInt(st.nextToken());
                    //System.out.println(N + " :: " + S + " :: " + P);
                    int c = 0;
                    while(st.hasMoreTokens()) {
                        float temp = Float.parseFloat(st.nextToken());
                        //double a = temp/3.0;
                        list[c][0] = Math.round(temp/3.0f);
                        list[c][1] = Math.round(temp/3.0f);
                        list[c][2] = (int)(temp - (2 * Math.round(temp/3.0f)));
                        //System.out.println(temp + " :: " + list[c][0] + " " + list[c][1] + " " + list[c][2]);
                        c++;
                    }
                   

                    /* calculations */
                    int counter = 0;
                    for(int[] i : list) {

                        if(i[0] >= P || i[1] >= P || i[2] >= P) {
                            counter++;
                        } else {
                            if(S > 0 ) {
                                double a = (i[0]+i[1]+i[2]) - P;
                                //System.out.println("a : " + a);
                                double b = a/2.0;
                                
                                if((P - b) <= 2 && a > 0) {
                                    //System.out.println("special " +  S + " : " + (P - b) + " :: pass");
                                   counter++;
                                    S--;
                                } else {
                                    //System.out.println("special " +  S + " : " + (P - b) + " :: fail");
                                }
                                
                            }
                        }

                        
                    }
                    //System.out.println("");
                    outer.println("Case #" + count + ": " + counter);
                    
                    count++;

                    //caser++;
                }


            }
            outer.close();

        } catch(IOException ex) {
            System.out.println("Error with IO you foooool");
        } catch(Exception ex) {
            System.out.println("Generic Error. Noob.");
            ex.printStackTrace();
        }
    }

}
