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.b;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.google.common.collect.ArrayListMultimap;

public final class Memory {

    private static Logger log = LoggerFactory.getLogger(Memory.class);

    public ArrayListMultimap<Integer, Triplet> data = ArrayListMultimap.create();

    private static int startFor(int a) {
        return a < 2 ? 0 : a - 2;
    }

    private static int endFor(int a) {
        return a > 8 ? 10 : a + 2;
    }

    public void init() {
        log.debug("init: start");
        for (int a = 0; a <= 10; ++a) {
            int bStart = startFor(a);
            int bEnd = endFor(a);
            for (int b = bStart; b <= bEnd; ++b) {
                int cStart = startFor(b);
                int cEnd = endFor(b);
                for (int c = cStart; c <= cEnd; ++c) {
                    int total = a + b + c;
                    data.put(total, Triplet.of(a, b, c, total));
                }
            }
        }
        log.debug("init: finished");
    }
}
