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 codejam2012.qualification;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class ProblemB {
    public static void main(String[] args) throws Exception {
        System.setIn(new FileInputStream("B-small-attempt0.in"));
        System.setOut(new PrintStream(new FileOutputStream("B-small-attempt0.out")));
        Scanner in = new Scanner(System.in);
        int testCase = in.nextInt();
        
        for(int i = 1; i <= testCase; i++) {
            int count = 0, count2 = 0;
            
            int n = in.nextInt();
            int s = in.nextInt();
            int p = in.nextInt();
            for(int j = 0; j < n; j++) {
                int t = in.nextInt();
                if(t >= 3*p-2)
                    count++;
                else if(3*p-4 >= 0 && t >= 3*p-4)
                    count2++;
            }
            count += (count2>s? s: count2);
            System.out.printf("Case #%d: %d%n", i, count);
        }
    }
}
