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 gcj.quals;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

public class T2 {
    public static void main(String[] args) {
        File fi = new File("/home/sighless/Documents/gcj/2");
        File fo = new File("/home/sighless/Documents/gcj/out");
        
        BufferedReader in = null;
        BufferedWriter out = null;
        
        try {
            in = new BufferedReader(new FileReader(fi));
        } catch (FileNotFoundException e1) {
            e1.printStackTrace();
        }
        
        try {
            out = new BufferedWriter(new FileWriter(fo));
        } catch (IOException e1) {
            e1.printStackTrace();
        }

        List<String> input = new ArrayList<String>();
        try {
            int lines = Integer.parseInt(in.readLine());
        
            String line = "";
            while(lines != 0) {
                line = in.readLine();
                
                input.add(line);
                lines--;
            }
        } catch (IOException e) {}

        String[] parts;
        int googlers = 0, surprises = 0, checkScore = 0, result = 0;
        Score googlerScore = new Score();
        for(int i = 0; i < input.size(); ++i) {
            parts = input.get(i).split(" ");
            
            googlers = Integer.parseInt(parts[0]);
            surprises = Integer.parseInt(parts[1]);
            checkScore = Integer.parseInt(parts[2]);
            
            result = 0;
            for(int g = 0; g < googlers; ++g) {
                googlerScore.init(Integer.parseInt(parts[g + 3]), surprises > 0 ? true : false);
                if(googlerScore.check(checkScore)) {
                    result++;
                    if(googlerScore.isSurprise()) surprises--;
                }
            }
            
            
            try {
                out.write("Case #" + (i + 1) + ": " + result + "\n");
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        
        try {
            out.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

class Score {
    int total;
    boolean surprise;
    
    public void init(int total, boolean surprise) {
        this.total = total;
        this.surprise = surprise;
    }
    
    public boolean check(int singleScore) {
        int average = total / 3;
        
        if(average >= singleScore) {surprise = false; return true;}
        
        int distance = singleScore - average; 
        switch(total - (average * 3)) {
        case 0:
            if((distance == 1) && average >= 1 && surprise) return true;
            break;
        case 1:
            if(distance == 1) {surprise = false; return true;}
            break;
        case 2:
            if(distance == 1) {surprise = false; return true;}
            if((distance == 2)  && surprise) return true;
            break;
        }
        
        return false;
    }
    
    public boolean isSurprise() {
        return surprise;
    }
}