package codejam;

import fixjava.Pair;

public class Utils {

	public static long minLong(long firstVal, long... otherVals) {
		long minVal = firstVal;
		for (int i = 0; i < otherVals.length; i++)
			minVal = Math.min(firstVal, otherVals[i]);
		return minVal;
	}

	public static int minInt(int firstVal, int... otherVals) {
		int minVal = firstVal;
		for (int i = 0; i < otherVals.length; i++)
			minVal = Math.min(firstVal, otherVals[i]);
		return minVal;
	}

	public static float minFloat(float firstVal, float... otherVals) {
		float minVal = firstVal;
		for (int i = 0; i < otherVals.length; i++)
			minVal = Math.min(firstVal, otherVals[i]);
		return minVal;
	}

	/**
	 * ArgMin returned as a Pair<Integer, Integer>(index, value). Array must
	 * have at least one value.
	 */
	public static Pair<Integer, Integer> argMin(int[] arr) {
		int min = arr[0];
		int argMin = 0;
		for (int i = 1; i < arr.length; i++) {
			if (arr[i] < min) {
				min = arr[i];
				argMin = i;
			}
		}
		return new Pair<Integer, Integer>(argMin, min);
	}

	/**
	 * ArgMax returned as a Pair<Integer, Integer>(index, value). Array must
	 * have at least one value.
	 */
	public static Pair<Integer, Integer> argMax(int[] arr) {
		int max = arr[0];
		int argMax = 0;
		for (int i = 1; i < arr.length; i++) {
			if (arr[i] > max) {
				max = arr[i];
				argMax = i;
			}
		}
		return new Pair<Integer, Integer>(argMax, max);
	}

}

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
import java.io.*;
import java.util.*;
/**
 *
 * @author Maleen
 */
public class B {
     public static void main(String[] args) throws FileNotFoundException, IOException {
        Scanner sc = new Scanner(new File("in/B.txt"));
        PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("Bout.txt")));
        
        int[] SMax = new int[31];
        int[] NMax = new int[31];
        SMax[0] = 0; NMax[0] = 0;
        for (int i=1;i<=30;i++){
            SMax[i] = Math.min((i+1)/3 +1,10);
            NMax[i] = Math.min((i-1)/3 +1,10);
            
            System.out.println(i+ " "+NMax[i] +" "+ SMax[i]);
        }
        int T = sc.nextInt();
        for (int t=0;t<T;t++){
            int N = sc.nextInt();
            int S = sc.nextInt();
            int P = sc.nextInt();
            int clear = 0;
            int margin = 0;
            for (int i=0;i<N;i++){
                int n = sc.nextInt();
                if (NMax[n] >=P) clear ++;
                else if (SMax[n] >=P) margin++;
            }
            System.out.println("S "+S +" clear "+ clear +" margin "+margin);
            out.println("Case #"+(t+1) + ": "+ (clear + Math.min(margin, S)));
        }
        out.close();
     }
}
