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.*;
import java.io.*;

public class ProblemB {

	static boolean surprising(int s, int p)
	{
		int r = s % 3;
		int x;
		if (r == 0)
			x = (s - 3) / 3;
		else if (r == 1)
			x = (s - 4) / 3;
		else
			x = (s - 2) / 3;
		if (x >= 0 && x <= 8)
		{
			return (x + 2) >= p;
		}
		else
			return false;
	}
	
	static boolean nonsurprising(int s, int p)
	{
		int r = s % 3;
		int x;
		if (r == 0)
		{
			x = s / 3;
			return x >= 0 && x <= 10 && x >= p;
		}
		else if (r == 1)
			x = (s - 1) / 3;
		else
			x = (s - 2) / 3;
		return (x >= 0 && x <= 9 && x + 1 >= p);
	}

	public static void main(String[] args) throws FileNotFoundException {
		Scanner cin = new Scanner(new File("B.txt"));
		PrintStream cout = new PrintStream("B.ans");
		int caseN = cin.nextInt();
		for (int caseI = 1; caseI <= caseN; caseI++)
		{
			int n = cin.nextInt();
			int s = cin.nextInt();
			int p = cin.nextInt();
			int scores[] = new int[n];
			boolean sur[] = new boolean[n];
			boolean non[] = new boolean[n];
			for (int i=0; i<n; i++)
				scores[i] = cin.nextInt();
			int ans = 0;
			int inc = 0, dec = 0, rem = 0;
			for (int i=0; i<n; i++)
			{
				sur[i] = surprising(scores[i], p);
				non[i] = nonsurprising(scores[i], p);
				if (non[i])
					ans++;
				if (sur[i] == non[i])
					rem++;
				else if (sur[i])
					inc++;
				else
					dec++;
			}
			int delta;
			delta = Math.min(s, inc);
			s -= delta;
			ans += delta;
			delta = Math.min(s, rem);
			s -= delta;
			delta = Math.min(s, dec);
			s -= delta;
			ans -= delta;
			cout.println("Case #" + caseI + ": " + ans);
		}
	}

}
