import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;


public class Dancing {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		// read input file
		File file = new File("B-small-attempt4.in");
		//File file = new File("input.txt");
		BufferedReader br = new BufferedReader(new FileReader(file));
		String ln = "";
		int count = Integer.parseInt(br.readLine());

		// write output file
		File out = new File("outB.txt");
		BufferedWriter bw = new BufferedWriter(new FileWriter(out));
		
		int y = 0;
		for (int i=0; i < count; i++){
			ln = br.readLine();
			y = getY(ln);
			bw.write("Case #" + (i+1) + ": " + y);
			bw.newLine();
		}
		bw.close();
	}
	
	private static int getY(String str) {
		String[] data = str.split(" ");
		int n = Integer.parseInt(data[0]);
		int s = Integer.parseInt(data[1]);
		int p = Integer.parseInt(data[2]);
		int[] t = new int[n];
		for (int i=0; i < n; i++){
			t[i] = Integer.parseInt(data[i+3]);
		}
		int y = 0;
		int base = 0;
		for(int j=0; j < t.length; j++){
			base = t[j] / 3;
			if(base >= p) { y++; }
			else if(base == p-1){
				if(t[j] - (base+p) > base-1 && t[j] > 0){
					y++;
				} else if(s>0 && t[j] - (base+p) > base-2 && t[j] > 0){
					s -= 1;
					y++;
				}
			} else if(base == p-2){
				if(s > 0 && t[j] - (base+p) > base-1 && t[j] > 0){
					s -= 1;
					y++;
				}
			}
		}
		
		return y;
	}

}

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Scanner;


public class Dancing {

    public static HashMap<Integer,ArrayList<ArrayList<Integer>>> unsurprising = new HashMap<Integer,ArrayList<ArrayList<Integer>>>();
    public static HashMap<Integer,ArrayList<ArrayList<Integer>>> surprising = new HashMap<Integer,ArrayList<ArrayList<Integer>>>();

    /**
     * @param args
     */
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int cases = scanner.nextInt();
        for(int i = 0;i<=10;i++){
            for(int j = i;j<=i+2;j++){
                for(int k = j; k<=i+2;k++){
                    Integer sum = i+k+j;
                    if(k-i==2||j-i==2){
                        ArrayList<ArrayList<Integer>> arrs = new ArrayList<ArrayList<Integer>>();
                        if(surprising.containsKey(sum)){
                            arrs = surprising.get(sum);
                        }
                        ArrayList<Integer> arr = new ArrayList<Integer>();
                        arr.add(i);
                        arr.add(j);
                        arr.add(k);
                        arrs.add(arr);
                        surprising.put(sum, arrs);
                    } else {
                        ArrayList<ArrayList<Integer>> arrs = new ArrayList<ArrayList<Integer>>();
                        if(unsurprising.containsKey(sum)){
                            arrs = unsurprising.get(sum);
                        }
                        ArrayList<Integer> arr = new ArrayList<Integer>();
                        arr.add(i);
                        arr.add(j);
                        arr.add(k);
                        arrs.add(arr);
                        unsurprising.put(sum, arrs);
                    }
                }
            }
        }

        for(int i = 1;i<=cases;i++){
            int numPeople = scanner.nextInt();
            int surprisingNums = scanner.nextInt();
            int lookFor = scanner.nextInt();
            int[] scores = new int[numPeople];
            for(int j = 0;j<numPeople;j++){
                scores[j] = scanner.nextInt();
            }
            System.out.println("Case #"+i+": "+solve(numPeople,surprisingNums,lookFor,scores));
        }
    }

    private static int solve(int numPeople, int surprisingNums, int lookFor,
            int[] scores) {
        int sum = 0;
        Binomial binomial = new Binomial(numPeople,surprisingNums);
        while(binomial.hasMore()){
            int[] combo = binomial.getNext();
            int currentSum = 0;
            int index=0;
            for(int i = 0;i<scores.length;i++){
                if(index<combo.length&&combo[index]==i){
                    ArrayList<ArrayList<Integer>> arrs = surprising.get(scores[i]);
                    if(arrs==null)break;
                    boolean found = false;
                    for(int j = 0;j<arrs.size();j++){
                        if(arrs.get(j).get(1)>=lookFor||arrs.get(j).get(2)>=lookFor||arrs.get(j).get(0)>=lookFor){
                            found = true;
                        }
                    }
                    if(found){
                        currentSum++;
                    }
                    index++;
                } else {
                    ArrayList<ArrayList<Integer>> arrs = unsurprising.get(scores[i]);
                    boolean found = false;
                    for(int j = 0;j<arrs.size();j++){
                        if(arrs.get(j).get(1)>=lookFor||arrs.get(j).get(2)>=lookFor||arrs.get(j).get(0)>=lookFor){
                            found = true;
                        }
                    }
                    if(found){
                        currentSum++;
                    }
                }
            }
            if(currentSum>sum)
                sum = currentSum;
        }
        return sum;
    }
}
