/*
 * 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.util.HashSet;
import java.util.Scanner;


public class Dance {

    private int[] mTotalScores;
    private int mMaxSurprise;
    private int mP;
    private int mAnswer;
    private HashSet<String> mCache = new HashSet<String>();
    
    public Dance(int[] totalScores, int maxSurprise, int p) {
        mTotalScores = totalScores;
        mMaxSurprise = maxSurprise;
        mP = p;
        recurse(0, 0, 0);
    }
    
    public int getAnswer() {
        return mAnswer;
    }
    
    private void recurse(int index, int surprises, int qualified) {
        String idx = index + "_" + surprises + "_" + qualified;
        if (mCache.contains(idx)) {
            return;
        }
        else {
            mCache.add(idx);
        }
        if (surprises > mMaxSurprise) return;
        if (index >= mTotalScores.length) {
            if (qualified > mAnswer) {
                mAnswer = qualified;
            }
            return;
        }
        
        Pair[] pos = scoreVariations(mTotalScores[index]);
        for (int i = 0; i < pos.length; i++) {
            int localSurprises = surprises;
            int localQualified = qualified;
            if (pos[i].surprise) localSurprises++;
            if (pos[i].max >= mP) localQualified++;
            recurse(index + 1, localSurprises, localQualified);
        }
    }
    
    // Get possible score variations
    public static Pair[] scoreVariations(int score) {
        HashSet<Pair> set = new HashSet<Pair>();
        
        int fStart = score / 3;
        int fEnd = Math.min(10, fStart + 3);
        
        for (int i = fStart; i <= fEnd; i++) {
            int sStart = i;
            int sEnd = Math.min(10, i + 2);
            for (int j = sStart; j <= sEnd; j++) {
                int k = score - i - j;
                
                if (Math.abs(i - k) > 2 || Math.abs(j - k) > 2 || k > 10 || k < 0) {
                    // Invalid case
                    continue;
                }
                
                boolean surprise = Math.abs(i - k) == 2 || Math.abs(j - k) == 2 || Math.abs(i - j) == 2;
                int max = Math.max(i, Math.max(j, k));
                set.add(new Pair(max, surprise));
            }
        }
        
        return set.toArray(new Pair[0]);
    }
    
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int num = in.nextInt();
        
        for (int i = 0; i < num; i++) {
            int num2 = in.nextInt();
            int s = in.nextInt();
            int p = in.nextInt();
            int[] scores = new int[num2];
            for (int j = 0; j < num2; j++) {
                scores[j] = in.nextInt();
            }
            Dance d = new Dance(scores, s, p);
            System.out.println("Case #" + (i + 1) + ": " + d.getAnswer());
        }
    }

}
