package com.example;

import java.io.IOException;
import java.util.List;

public class ProblemB {
    
    enum Result {
	INSUFFICIENT,
	SUFFICIENT,
	SUFFICIENT_WHEN_SURPRISING
    }

    public static void main(String[] a) throws IOException {

	List<String> lines = FileUtil.getLines("/B-large.in");
	
	int cases = Integer.valueOf(lines.get(0));
	
	for(int c=0; c<cases; c++) {
	    String[] tokens = lines.get(c+1).split(" ");
	    
	    int n = Integer.valueOf(tokens[0]); // N = number of Googlers
	    int s = Integer.valueOf(tokens[1]); // S = number of surprising triplets
	    int p = Integer.valueOf(tokens[2]); // P = __at least__ a score of P
	    
	    int sumSufficient = 0;
	    int sumSufficientSurprising = 0;
	    
	    for(int i=0; i<n; i++) {
		int points = Integer.valueOf(tokens[3+i]);
		
		switch(test(points, p)) {
		case SUFFICIENT:
		    sumSufficient++;
		    break;
		    
		case SUFFICIENT_WHEN_SURPRISING:
		    sumSufficientSurprising++;
		    break;
		}
		
//		uSystem.out.println("points "+ points +" ? "+ p +" => "+ result);
	    }
	    
	    System.out.println("Case #"+ (c+1) +": "+ (sumSufficient + Math.min(s, sumSufficientSurprising)));
	    
//	    System.out.println();
//	    System.out.println("N="+ n +", S="+ s +", P="+ p);
//	    System.out.println();
	}
    }

    private static Result test(int n, int p) {
	int fac = n / 3;
	int rem = n % 3;
	
	if(rem == 0) {
	    
//	    int triplet0[] = { fac, fac, fac };
//	    print(n, triplet0);
	    
	    if(fac >= p) {
		return Result.SUFFICIENT;
	    }
	    
	    if(fac > 0 && fac < 10) {
		
		if(fac+1 >= p) {
		    return Result.SUFFICIENT_WHEN_SURPRISING;
		}
		
//		int triplet1[] = { fac+1, fac, fac-1 }; // surprising 
//		print(n, triplet1);
	    }
	    
	    
	} else if(rem == 1) {
	    
//	    int triplet0[] = { fac+1, fac, fac };
//	    print(n, triplet0);
	    
	    if(fac+1 >= p) {
		return Result.SUFFICIENT;
	    }
	    
//	    if(fac > 0 && fac < 10) {
//		int triplet1[] = { fac+1, fac+1, fac-1 };
//		print(n, triplet1);
//	    }
	    
	} else if(rem == 2) {
	    
//	    int triplet0[] = { fac+1, fac+1, fac };
//	    print(n, triplet0);
	    
	    if(fac+1 >= p) {
		return Result.SUFFICIENT;
	    }
	    
	    if(fac < 9) {
//		int triplet1[] = { fac+2, fac, fac }; // surprising
//		print(n, triplet1);

		if(fac+2 >= p) {
		    return Result.SUFFICIENT_WHEN_SURPRISING;
		}
	    }
	    
	} else {
	    throw new RuntimeException("error");
	}
	
	return Result.INSUFFICIENT;
//	System.out.println();
//	System.out.println(n +" => "+ div3 +" ("+ rem +")");
    }
    
//    private static void print(int n, int[] triplet) {
//	System.out.println("n="+ n +" ("+ (n/3) +","+ (n%3) +") => ["+ triplet[0] +","+ triplet[1] +","+ triplet[2] +"]" + (triplet[0]-triplet[2] > 1 ? " *" : ""));
//    }
    
}

/**
 * @(#)Text1.java
 *
 *
 * @author
 * @version 1.00 2012/4/14
 */

import java.util.*;
import java.io.*;

public class B {

	public static int diff(int a, int b, int c) {
		int max = 0;
		if(Math.abs(a-b) > max) max = Math.abs(a-b);
		if(Math.abs(b-c) > max) max = Math.abs(b-c);
		if(Math.abs(c-a) > max) max = Math.abs(c-a);
		return max;
	}

	public static int max(int a, int b, int c) {
		return Math.max(Math.max(a, b), c);
	}

	public static int combo(int score, int best) {
		double avg = score/3.0;
		int min = 3;
		for(int i = 0; i <= 11; i++) {
			for(int j = 0; j <= 11; j++) {
				for(int k = 0; k <= 11; k++) {
					if(i + j + k == score && max(i, j, k) >= best) {
						int s = diff(i, j, k);
						//System.out.println("	S: " + score + " B: " + best + " ("+i+", "+j+", "+k+")" + " " + s);

						if(s < min) min = s;
						if(min == 0 || min == 1) return min;
					}
				}
			}
		}
		//System.out.println("		MIN: " + min);
		return min;

	}


    public static void main(String [] argz) throws IOException {
    	Scanner reader = new Scanner(new File("B-large.in"));
    	int numCases = reader.nextInt();
    	reader.nextLine();

		FileWriter fstream = new FileWriter("out.txt");
		BufferedWriter out = new BufferedWriter(fstream);


    	for(int i = 0; i < numCases; i++) {
    		ArrayList<Integer> scores = new ArrayList<Integer>();
    		Scanner lineReader = new Scanner(reader.nextLine());
    		while(lineReader.hasNext()) scores.add(lineReader.nextInt());
			int googlers = scores.remove(0);
			int surprising = scores.remove(0);
			int best = scores.remove(0);
			int amount = 0;

			//System.out.println("\n\n\nCase #" + (i+1) + " best: " + best);
			for(int j = 0; j < scores.size(); j++) {
				int current = combo(scores.get(j), best);
				if(current == 2 && surprising > 0) {
					amount++;
					surprising--;
				}
				if(current == 1 || current == 0) amount++;
				//System.out.println("AMT: " + amount + "	SUR: " + surprising);
			}
			//System.out.println();
    		out.write("Case #" + (i+1) + ": " + amount + "\n");

    	}
		out.close();
    }
}