/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package IO;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
    
/**
 * 
 * @author dannocz
 */
public class InputReader {
    
    public static Input readFile(String filename){
        try {
              
              /*  Sets up a file reader to read the file passed on the command
          77        line one character at a time */
              FileReader input = new FileReader(filename);
              
              /* Filter FileReader through a Buffered read to read a line at a
                 time */
              BufferedReader bufRead = new BufferedReader(input);
              
              String line;    // String that holds current file line
              int count = 0;  // Line number of count 
              ArrayList<String> cases= new ArrayList<String>();
              
              // Read first line
              line = bufRead.readLine();
              int noTestCases=Integer.parseInt(line);
              count++;
              
              // Read through file one line at time. Print line # and line
              while (count<=noTestCases){
                  //System.out.println("Reading. "+count+": "+line);
                  line = bufRead.readLine();
                  cases.add(line);
                  count++;
              }
              
              bufRead.close();
              
              return new Input(noTestCases,cases);
              
          }catch (ArrayIndexOutOfBoundsException e){
              /* If no file was passed on the command line, this expception is
              generated. A message indicating how to the class should be
              called is displayed */
              e.printStackTrace();        
  
          }catch (IOException e){
              // If another exception is generated, print a stack trace
              e.printStackTrace();
          }
        
        return null;
          
      }// end main
    }

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class B {
	static int[][] dp;
	static int[] sum;
	static int p;

	public static int abs(int a) {
		return (a < 0) ? -a : a;
	}

	public static int go(int i, int j) {
		if (j < 0)
			return -1000;
		if (i == sum.length) {
			if (j != 0)
				return -1000;
			else
				return 0;
		}

		else if (dp[i][j] != -1)
			return dp[i][j];
		else {
			int max = 0;
			for (int a = 0; a <= 10 && a <= sum[i]; a++)
				for (int b = a; b <= a + 2 && b <= 10 && a + b <= sum[i]; b++)
					for (int c = a; c <= a + 2 && c <= 10
							&& a + b + c <= sum[i]; c++) {
						if (a + b + c == sum[i]) {
							int cool = 0;
							int awesome = 0;
							if (b - a == 2 || c - a == 2)
								cool = 1;
							if (a >= p || b >= p || c >= p)
								awesome = 1;
							max = Math.max(max, awesome + go(i + 1, j - cool));
						}
					}
			return dp[i][j] = max;
		}
	}

	public static void main(String[] args) throws Exception {
		BufferedReader in = new BufferedReader(new InputStreamReader(
				new FileInputStream("B.in")));
		PrintWriter out = new PrintWriter("B.out");
		int tc = Integer.parseInt(in.readLine());
		for (int cc = 1; cc <= tc; cc++) {
			StringTokenizer strtok = new StringTokenizer(in.readLine(), " ");
			int n = Integer.parseInt(strtok.nextToken());
			int s = Integer.parseInt(strtok.nextToken());
			p = Integer.parseInt(strtok.nextToken());
			dp = new int[n][s + 1];
			for (int[] a : dp)
				Arrays.fill(a, -1);
			sum = new int[n];
			for (int i = 0; i < n; i++)
				sum[i] = Integer.parseInt(strtok.nextToken());
			out.printf("Case #%d: %d\n", cc, go(0, s));
		}
		out.close();
		in.close();
	}
}
