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.io.File;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.util.*;

public class main {

    static int numberPeriod(int n, int len) {
        if (len == 2 && n / 10 == n % 10) return 1;
        if (len == 4 && n % 100 == n / 100) return 2;
        if (len == 6 && n % 100 == n / 10000 && n % 100 == n / 100 % 100) return 2;
        if (len == 6 && n % 1000 == n / 1000) return 3;
        return len;
    }

    static int numberLength(int n) {
        int len = 0;
        while (n > 0) {
            n /= 10;
            len++;
        }
        return len;
    }

    main() throws FileNotFoundException {
        Scanner sc = new Scanner(new File("B-small-attempt0.in"));
        PrintWriter out = new PrintWriter("result.txt");
        int tests = sc.nextInt();
        for (int t = 1; t <= tests; t++) {
            int n = sc.nextInt();
            int s = sc.nextInt();
            int p = sc.nextInt();
            Map<Integer, ArrayList<Decompose>> map = new TreeMap<>();
            ArrayList<Integer> scores = new ArrayList<>();

            for (int m = 0; m < n; m++) {
                int g = sc.nextInt();
                scores.add(g);
                map.put(g, dec(g));
                //out.println(dec(g).toString());
            }

            int ww = 0;
            int w = 0;
            int cw = 0;
            for (int i = 0; i < n; i++) {
                if (isDecomposeThere(map.get(scores.get(i)), p, true) && isDecomposeThere(map.get(scores.get(i)), p, false)) {
                    ww++;
                } else if (isDecomposeThere(map.get(scores.get(i)), p, true)) {
                    w++;
                } else if (isDecomposeThere(map.get(scores.get(i)), p, false)) {
                    cw++;
                }
            }

            if (w >= s) {
                out.printf("Case #%d: %d\n", t, s + cw + ww);
            } else {
                //s -= w;
                out.printf("Case #%d: %d\n", t, w + ww + cw);
            }
        }
        out.flush();
    }

    public static void main(String[] args) throws FileNotFoundException {
        main m = new main();
    }

    public boolean isDecomposeThere(ArrayList<Decompose> decomposes, int p, boolean surprise) {
        for (Decompose dec : decomposes) {
            if (dec.a >= p && dec.surprise == surprise) return true;
        }
        return false;
    }

    public ArrayList<Decompose> dec(int n) {
        ArrayList<Decompose> list = new ArrayList<>();
        for (int i = 0; i <= 10; i++) {
            for (int j = 0; j <= i; j++) {
                for (int k = 0; k <= j; k++) {
                    if (i - j <= 2 && j - k <= 2 && i - k <= 2 && i + j + k == n) {
                        boolean surprise = (i - j == 2 || j - k == 2 || i - k == 2);
                        list.add(new Decompose(i, j, k, surprise));
                    }
                }
            }
        }
        return list;
    }

    class Decompose {
        int a, b, c;
        boolean surprise;

        public Decompose(int a, int b, int c, boolean surprise) {
            this.a = a;
            this.b = b;
            this.c = c;
            this.surprise = surprise;
        }

        @Override
        public String toString() {
            return "" + a + " " + b + " " + c + " " + surprise;
        }
    }

}