import java.io.*;
import java.math.*;
import java.util.*;
import java.text.*;

public class b {
    public static void main(String[] args) {
        Scanner sc = new Scanner(new BufferedInputStream(System.in));

        int T = sc.nextInt();

        for (int casenumber = 1; casenumber <= T; ++casenumber) {

            int n = sc.nextInt();
            int s = sc.nextInt();
            int p = sc.nextInt();

            int[] ts = new int[n];
            for (int i = 0; i < n; ++i)
                ts[i] = sc.nextInt();

            int thresh1 = (p == 1 ? 1 : (3 * p - 4));
            int thresh2 = (3 * p - 2);

            int count1 = 0, count2 = 0;

            for (int i = 0; i < n; ++i) {
                if (ts[i] >= thresh2) {
                    ++count2;
                    continue;
                }
                if (ts[i] >= thresh1) {
                    ++count1;
                }
            }

            if (count1 > s) {
                count1 = s;
            }

            System.out.format("Case #%d: %d%n", casenumber, count1 + count2);
        }
    }
}

// Dancing With the Googlers

import java.io.*;

public class DancingWithGooglers {
	public static void main(String[] args) throws Exception {
		String inputPath = args[args.length-2];
		String outputPath = args[args.length-1];
		
		BufferedReader br = new BufferedReader(new FileReader(inputPath));
		int numberOfTestCases = Integer.parseInt(br.readLine());
		
		StringBuilder output = new StringBuilder();
		
		for (int i=1; i<=numberOfTestCases; i++) {
			String components[] = br.readLine().split(" ");
			int numberOfDancers = Integer.parseInt(components[0]);
			int numberOfSurprisingResults = Integer.parseInt(components[1]);
			int bestScore = Integer.parseInt(components[2]);
			int numberOfBestScores = 0;
			
			for (int totalScoreIndex=3; totalScoreIndex<(3+numberOfDancers); totalScoreIndex++) {
				int totalScore = Integer.parseInt(components[totalScoreIndex]);
				int average = totalScore / 3;
				int overflow = totalScore % 3;
				
				if (average >= bestScore) {
					numberOfBestScores++;
				} else if ((overflow != 0) && ((average+1) >= bestScore)) {
					numberOfBestScores++;
				} else if (numberOfSurprisingResults != 0) {
					if ((overflow == 2) && ((average+overflow) >= bestScore)) {
						numberOfBestScores++;
						numberOfSurprisingResults--;
					} else if ((overflow == 0) && (average > 0) && ((average+1) >= bestScore)) {
						numberOfBestScores++;
						numberOfSurprisingResults--;
					}
				}
				
//				System.out.println(totalScore + " " + average + " " + overflow + " " + numberOfBestScores);
			}
//			System.out.println("Case #" + i + ": " + numberOfBestScores + "\n");
			output.append("Case #" + i + ": " + numberOfBestScores + "\n");
		}
		
		BufferedWriter bw = new BufferedWriter(new FileWriter(outputPath));
		String outputString = output.toString();
		bw.write(outputString, 0, outputString.length());
		bw.close();
	}
}
