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

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package googlers;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
/**
 *
 * @author Floran
 */
public class Googlers {

    int nbCase;
	static String inName;
	static String outName;
        public final char h=(char) 104;
	
	public static void solve() throws IOException{
		PrintWriter out=new PrintWriter(new BufferedWriter(new FileWriter(outName)));
		//Scanner in=new Scanner("A-small-practice.txt");
		BufferedReader in=new BufferedReader(new FileReader(inName));
		String ligne=in.readLine();
                // nb de cas
		System.out.println(ligne);
		int nbCase=Integer.parseInt(ligne);
                //compte
                int count=0;
                for(int i=1;i<=nbCase;i++){
                    int ns=0;//nb suprise
                    count=0;
                    String[] parametre=in.readLine().split(" ");
                    System.out.println("lenght"+parametre.length);
                    int nb=Integer.parseInt(parametre[0]);//nb de participant
                    System.out.println("nb"+nb);
                    int suprise=Integer.parseInt(parametre[1]);//nb de triplet surprise
                    System.out.println("sup"+suprise);
                    int min=Integer.parseInt(parametre[2]);//un quote du triplet doit Ãªtre >=min
                    for(int m=3;m<nb+3;m++){
                        //int[][] tab=decomposition(Integer.parseInt(parametre[i]));
                        int[] tab=decomp(Integer.parseInt(parametre[m]));
                        if(tab.length==1){
                            //if(tab[0][2]>=min)
                            if(tab[0]>=min)
                                count++;
                        }
                        else{
                            //if(tab[0][2]>=min)
                            if(tab[0]>=min)
                                count++;
                            //else if(tab[0][2]>=min &&ns<=suprise){
                            else if(tab[1]>=min && ns<suprise){
                                ns++;
                                count++;
                            }
                        }
                    }
                    out.println("Case #"+i+": "+count);	
		}
		out.flush();
		out.close();
		in.close();
	}
   /* public static int[][] decomposition(int quote){
        int mod=quote%3;
        int div=quote/3;
        int[][] tab;
        if(mod==1){
            tab=new int[1][3];
            tab[0][0]=div;
            tab[0][1]=div;
            tab[0][2]=div+1;
            return tab;
        }
        if(mod==2){
            tab=new int[2][3];
            tab[0][0]=div;
            tab[0][1]=div+1;
            tab[0][2]=div+1;
            
            tab[1][0]=div;
            tab[1][1]=div;
            tab[1][2]=div+2;
            
            return tab;
        }
        else{
            tab=new int[2][3];
            tab[0][0]=div;
            tab[0][1]=div;
            tab[0][2]=div;
            
            tab[1][0]=div;
            tab[1][1]=div-1;
            tab[1][2]=div+1;
            
            return tab;
        }
    }*/
    public static int[] decomp(int quote){
        int mod=quote%3;
        int div=quote/3;
        int[] tab;
        if(mod==1){
            tab=new int[1];
            tab[0]=div+mod;
            return tab;
        }
        if(mod==2){
            tab=new int[2];
            tab[0]=div+(mod/2);
            tab[1]=div+mod;
            
            return tab;
        }
        else{
            tab=new int[2];
            tab[0]=div;
            if(quote==0)
                tab[1]=div;
            else
                tab[1]=div+1;
            
            return tab;
        }
    }
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        //inName="A-small-practice.txt";
                //inName="test.txt";
		//outName="solution7.txt";
		inName="B-small-attempt4.in";
		outName="solution_small4.txt";
		//inName="A-large-practice.in";
		//outName="Large_solution.txt";
		try{
			solve();
		}
		catch(IOException e){
			System.out.println(e.getMessage());
		}
		System.out.println("fini");
    }
}
