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 codejam.surprisingGooglers;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

public class Solver {

	public int getMaximumNumberOfPHavers(int numberOfSurprises, int bestResult, Integer... totals){
		List<PossibleSurpriseCase> allCases = buildCases(numberOfSurprises, Arrays.asList(totals));
		int maxPHavers = 0;
		for (PossibleSurpriseCase surpriseCase : allCases) {
			maxPHavers = Math.max(surpriseCase.getMaximumPHavers(bestResult), maxPHavers);
		}
		return maxPHavers;
	}

	private List<PossibleSurpriseCase> buildCases(int numberOfSurprises, List<Integer> totals) {
		if (totals.isEmpty()) return Collections.singletonList(PossibleSurpriseCase.trivial());
		List<PossibleSurpriseCase> surprise = combine(true, totals.get(0), buildCases(numberOfSurprises-1, totals.subList(1, totals.size())));
		if (numberOfSurprises == totals.size()) return surprise;
		List<PossibleSurpriseCase> noSurprise = combine(false, totals.get(0), buildCases(numberOfSurprises, totals.subList(1, totals.size())));
		if (numberOfSurprises <= 0) return noSurprise;
		return append(surprise,	noSurprise);
	}
	
	private List<PossibleSurpriseCase> append(
			List<PossibleSurpriseCase> one,
			List<PossibleSurpriseCase> two) {
		List<PossibleSurpriseCase> r = new ArrayList<PossibleSurpriseCase>(one.size() + two.size());
		r.addAll(one);
		r.addAll(two);
		return r;
	}

	public static List<PossibleSurpriseCase> combine(boolean isSurprise, int score, List<PossibleSurpriseCase> cases) {
		List<PossibleSurpriseCase> r = new ArrayList<PossibleSurpriseCase>(cases.size());
		for (PossibleSurpriseCase surpriseCase : cases) {
			r.add(PossibleSurpriseCase.combine(isSurprise, score, surpriseCase));
		}
		return r;
	}

	
}
