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

}

import java.util.Scanner;

/*
 * el resto es 0 --> puede ser caso especial y no
 * 		15 --> 5 5 5 Ã³ 4 5 6
 * el resto es 1 --> puede ser caso especial y no
 * 		16 --> 4 6 6 Ã³ 5 5 6
 * el resto es 2 --> puede ser caso especial y no
 * 		17 --> 5 7 7 Ã³ 5 6 6 
 */

public class B {
	public static void main(String[] args) {
		final int JUDGES = 3;
		final int MINSCORE = 0;
		Scanner in = new Scanner(System.in);
		int t = in.nextInt();
		for (int i = 1; i <= t; i++) {
			int n = in.nextInt();
			int s = in.nextInt();
			int p = in.nextInt();
			int success = 0;
			for (int j = 0; j < n; j++) {
				int totalScores = in.nextInt();
				int score = totalScores / JUDGES;
				int rest = totalScores % JUDGES;
				if (totalScores==MINSCORE) {
					if (p==MINSCORE) { 
						success++;
					}
				} else if (score >= p || (score+1>=p && rest>=1)) {
					success++;
				} else if (score + 1 >= p && rest < 1 && s > 0) {
					success++;
					s--;
				} else if (score + 2 >= p && rest == 2 && s > 0) {
					success++;
					s--;
				}
			}
			System.out.format("Case #%d: %d\n", i, success);
		}
	}
}