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);
        }
    }
}

package R0;

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

/**
 *
 * @author Rohit
 */
public class QB {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int Tcases = s.nextInt();
        s.nextLine();
        for (int i = 0; i < Tcases; i++) {
            int Ngooglers = s.nextInt();
            int Ssurprising = s.nextInt();
            int Paim = s.nextInt();
            int score[] = new int[Ngooglers];
            for (int j = 0; j < Ngooglers; j++) {
                score[j] = s.nextInt();
            }
            /*
             * if score is <2, surprisingNotPossible,
             * if score is >=2 and <3*Paim - 4 surprisingPossible but bestNotPossible
             * if score is >=3*Paim-4 and <3*Paim-2 bestPossible only using surprising
             * if score is >=3*Paim-2 and <29 bestPossible and surprisingPossible
             * if score is >=29 bestPossible and surprisingNotPossible
             */
            int maxBest = 0;
            if (Paim == 0) {
                maxBest = Ngooglers;
            }
            if (Paim == 1) {
                for (int j = 0; j < Ngooglers; j++) {
                    if (score[j] >= 1) {
                        maxBest++;
                    }
                }
            }
            if (Paim > 1) {
                for (int j = 0; j < Ngooglers; j++) {
                    if (score[j] >= 3 * Paim - 4) {
                        if (score[j] < 3 * Paim - 2) {
                            if (Ssurprising > 0) {
                                maxBest++;
                                Ssurprising--;
                            }
                        } else {
                            maxBest++;
                        }
                    }
                }
            }
            //printing the output
            System.out.println("Case #" + (i + 1) + ": " + maxBest);

        }
    }
}
