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

import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author Lance Chen
 */
public class CodeHelper {

    private static String FILE_ROOT = "D:/workspace/googlecodejam/meta";

    public static List<List<String>> loadInputsExcludes(String fileName) {
        List<List<String>> result = new ArrayList<List<String>>();
        List<String> lines = FileUtil.readLines(FILE_ROOT + fileName);
        int index = 0;
        for (String line : lines) {
            if (index == 0) {
                index++;
                continue;
            }
            if (index % 2 == 1) {
                index++;
                continue;
            }
            List<String> dataList = new ArrayList<String>();
            String[] dataArray = line.split("\\s+");
            for (String data : dataArray) {
                if (data.trim().length() > 0) {
                    dataList.add(data);
                }
            }
            result.add(dataList);
            index++;
        }
        return result;
    }

    public static List<List<String>> loadInputs(String fileName) {
        List<List<String>> result = new ArrayList<List<String>>();
        List<String> lines = FileUtil.readLines(FILE_ROOT + fileName);
        for (String line : lines) {
            List<String> dataList = new ArrayList<String>();
            String[] dataArray = line.split("\\s+");
            for (String data : dataArray) {
                if (data.trim().length() > 0) {
                    dataList.add(data);
                }
            }
            result.add(dataList);
        }
        return result;
    }

    public static List<String> loadInputLines(String fileName) {
        return FileUtil.readLines(FILE_ROOT + fileName);
    }

    public static void writeOutputs(String fileName, List<String> lines) {
        FileUtil.writeLines(FILE_ROOT + fileName, lines);
    }
}

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.util.Scanner;


public class Googlers {

	/**
	 * @param args
	 * @throws Exception 
	 */
	public static void main(String[] args) throws Exception {
		// TODO Auto-generated method stub
		int[] minScoreWithSurprise = new int[11];
		int[] minScoreWithoutSurprise = new int[11];
		
		minScoreWithoutSurprise[0] = 0;
		minScoreWithSurprise[0] = 0;
		minScoreWithoutSurprise[1] = 1;
		minScoreWithSurprise[1] = 1;
		
		for(int i=2; i<minScoreWithoutSurprise.length; i++){
			int score = i * 3;
			minScoreWithoutSurprise[i] = score - 2 ; 
			minScoreWithSurprise[i] = score - 4 ;
			
		}
		
		Scanner sc = new Scanner(new File("B-small-attempt0.in"));
		BufferedWriter bw = new BufferedWriter(new FileWriter(new File("Output.txt")));
		StringBuilder sb = new StringBuilder(50);
		
		int numOfTestcase = sc.nextInt();
		int ans,p,googlers,minSWithoutS,minSwithS,numOfsurprisingTriplets,current;
		for(int i=0;i<numOfTestcase;i++){
			sb.setLength(0);
			googlers = sc.nextInt();
			numOfsurprisingTriplets = sc.nextInt();
			p = sc.nextInt();
			ans = 0;
			minSWithoutS = minScoreWithoutSurprise[p];
			minSwithS = minScoreWithSurprise[p];
			for(int j=0;j<googlers;j++){
				current = sc.nextInt();
				if(current >= minSWithoutS){
					ans++;
				}
				else if(numOfsurprisingTriplets > 0 && current>=minSwithS){
					ans++;numOfsurprisingTriplets--;
				}	
			}
			sb.append("Case #").append(i+1).append(": ").append(ans);
			bw.write(sb.toString());
			bw.newLine();
		}
		bw.close();

	}

}
