import java.io.BufferedReader;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;

public class CodeJam {

//	public static final String INPUT_FILE_PATH = "D://CodeJamInput.txt";
	public static final String INPUT_FILE_PATH = "D://B-large.in";
	public static final String OUTPUT_FILE_PATH = "D://CodeJamOutput.txt";

	public static List<String> readInput() {
		List<String> list = new ArrayList<String>();
		try {
			BufferedReader input = new BufferedReader(new FileReader(
					INPUT_FILE_PATH));
			try {
				String line = null;

				while ((line = input.readLine()) != null) {
					list.add(line);
				}
			} finally {
				input.close();
			}
		} catch (IOException ex) {
			ex.printStackTrace();
		}
		
		return list;
	}

	public static void writeOutput(List<String> output) {
		PrintWriter writer = null;
		try {
			writer = new PrintWriter(new FileWriter(OUTPUT_FILE_PATH));
			for (String line : output) {
				writer.println(line);
			}
			writer.flush();
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			if (writer != null)
				writer.close();
		}
	}
	
	public static void main(String[] args) {
		List<DanceFloor> danceFloors = DanceFloor.parseFromFile(CodeJam.readInput());
		List<String> output = new ArrayList<String>();

		for(int i = 0; i < danceFloors.size(); i++) {
			System.out.println(danceFloors.get(i));
			String line = "";
			line += "Case #" + (i + 1) + ": " + danceFloors.get(i).calculate();
			output.add(line);
		}
		
		CodeJam.writeOutput(output);
	}
}

class DanceFloor {

	private List<Integer> tripletsTotalCounts;
	private int surpriseCount;
	private int targetScore;
	private int dancersCount;

	public DanceFloor(List<Integer> tripletsTotalCounts, int surpriseCount,
			int targetScore, int dancersCount) {
		this.tripletsTotalCounts = tripletsTotalCounts;
		this.surpriseCount = surpriseCount;
		this.targetScore = targetScore;
		this.dancersCount = dancersCount;
	}

	public int calculate() {
		int result = 0;
		
		if (targetScore == 0) return dancersCount;
		
		for (int i = 0; i < tripletsTotalCounts.size(); i++) {
			int total = tripletsTotalCounts.get(i);

			if (total < (targetScore * 3 - 4)) {
				tripletsTotalCounts.remove(i--);
			} else if (total == 0) {
				tripletsTotalCounts.remove(i--);
			}
		}
		
		for (int i = 0; i < tripletsTotalCounts.size(); i++) {
			int total = tripletsTotalCounts.get(i);

			if ((surpriseCount > 0) && (total == targetScore * 3 - 4)) {
				result++;
				surpriseCount--;
				tripletsTotalCounts.remove(i--);
			} else if ((surpriseCount == 0) && (total == targetScore * 3 - 4)) {
				tripletsTotalCounts.remove(i--);
			}
		}
		
		for (int i = 0; i < tripletsTotalCounts.size(); i++) {
			int total = tripletsTotalCounts.get(i);

			if ((surpriseCount > 0) && (total == targetScore * 3 - 3)) {
				result++;
				surpriseCount--;
				tripletsTotalCounts.remove(i--);
			} else if ((surpriseCount == 0) && (total == targetScore * 3 - 3)) {
				tripletsTotalCounts.remove(i--);
			}
		}
		
		result += tripletsTotalCounts.size();
		
		return result;
	}

	public static List<DanceFloor> parseFromFile(List<String> readInput) {
		List<DanceFloor> result = new ArrayList<DanceFloor>();
		int testCaseCount = Integer.parseInt(readInput.get(0));

		for (int i = 0; i < testCaseCount; i++) {
			String line[] = readInput.get(i + 1).split(" ");

			List<Integer> totalCounts = new ArrayList<Integer>();
			for (int j = 0; j < Integer.parseInt(line[0]); j++) {
				totalCounts.add(Integer.parseInt(line[3 + j]));
			}

			result.add(new DanceFloor(totalCounts, Integer.parseInt(line[1]),
					Integer.parseInt(line[2]), Integer.parseInt(line[0])));
		}

		return result;
	}

	@Override
	public String toString() {
		return "dancersCount = " + dancersCount + "; surpriseCount = " + surpriseCount 
								 + "; targetScore = " + targetScore + "; tripletsTotalCounts" 
								 + tripletsTotalCounts.toString();
	}
}


import java.io.*;
import java.util.Arrays;
import java.util.HashSet;
import java.util.StringTokenizer;

/**
 * Created by IntelliJ IDEA.
 * User: 875k
 * Date: 4/14/12
 * Time: 12:08 AM
 * To change this template use File | Settings | File Templates.
 */
public class prQB {
    public static boolean notSurprising(int a, int b, int c) {
        return Math.abs(a - b) <= 1 && Math.abs(a - c) <= 1 && Math.abs(b - c) <= 1;
    }
    public static boolean surprising(int a, int b, int c) {
        return !notSurprising(a, b, c) && Math.abs(a - b) <= 2 && Math.abs(a - c) <= 2 && Math.abs(b - c) <= 2;
    }
    public static int[] points;
    public static int[] surpriseMax;
    public static int[] normalMax;
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new FileReader("prQB.in"));
        PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("prQB.out")));
        points = new int[101];
        surpriseMax = new int[101];
        normalMax = new int[101];
        int T = Integer.parseInt(br.readLine());
        for(int i = 0; i < T; i++) {
            Arrays.fill(points, -1);
            Arrays.fill(surpriseMax, -1);
            Arrays.fill(normalMax, -1);
            StringTokenizer st = new StringTokenizer(br.readLine());
            int N = Integer.parseInt(st.nextToken());
            int S = Integer.parseInt(st.nextToken());
            int p = Integer.parseInt(st.nextToken());
            for(int j = 0; j < N; j++) {
                points[j] = Integer.parseInt(st.nextToken());
                boolean found = false, founds = false;
                for(int a = Math.min(10, points[j]); a >= 0 && !(found && founds); a--) {
                    for(int b = Math.max(0, points[j] - a); b >= 0; b--) {
                        int c = points[j] - a - b;
                        if(notSurprising(a, b, c) && a >= normalMax[j]) {
                            found = true;
                            normalMax[j] = a;
                        }
                        if(surprising(a, b, c) && a >= surpriseMax[j]) {
                            founds = true;
                            surpriseMax[j] = a;
                        }
                    }
                }
            }
            //for(int j = 0; j < N; j++) { System.out.print(points[j] + "-" + normalMax[j] + "-" + surpriseMax[j] + ", "); } System.out.println();
            HashSet<Integer> hs = new HashSet<Integer>();
            for(int j = 0; j < N && S > 0; j++) {
                if(surpriseMax[j] >= p && normalMax[j] < p) {
                    hs.add(j);
                    S--;
                }
            }
            int c = hs.size();
            for(int j = 0; j < N; j++) {
                if(normalMax[j] >= p && !hs.contains(j)) c++;
            }
            out.println("Case #" + (i + 1) + ": " + c);
        }
        out.close();
        System.exit(0);
    }
}
