package code12.qualification;

import java.io.File;
import java.io.FileWriter;
import java.util.Scanner;

public class B {
	public static String solve(int N, int S, int p, int[] t) {
		
		// 3a 		-> (a, a, a), *(a - 1, a, a + 1)
		// 3a + 1	-> (a, a, a + 1), *(a - 1, a + 1, a + 1)
		// 3a + 2	-> (a, a + 1, a + 1), *(a, a, a + 2)
		
		int numPNoS = 0;
		int numPWithS = 0;
		
		for (int i = 0; i < N; i++) {
			int a = (int)Math.floor(t[i] / 3);
			int r = t[i] % 3;
			
			switch (r) {
			case 0:
				if (a >= p) {
					numPNoS++;
				} else if (a + 1 >= p && a - 1 >= 0) {
					numPWithS++;
				}
				break;
			case 1:
				if (a >= p || a + 1 >= p) {
					numPNoS++;
				}
				break;
			case 2:
				if (a >= p || a + 1 >= p) {
					numPNoS++;
				} else if (a + 2 >= p) {
					numPWithS++;
				}
				break;
			}
		}
		
		return "" + (numPNoS + Math.min(S, numPWithS));
	}

	public static void main(String[] args) throws Exception {
		// file name
		//String fileName = "Sample";
		//String fileName = "B-small";
		String fileName = "B-large";
		
		// file variable
		File inputFile = new File(fileName + ".in");
		File outputFile = new File(fileName + ".out");
		Scanner scanner = new Scanner(inputFile);
		FileWriter writer = new FileWriter(outputFile);

		// problem variable
		int totalCase;
		int N, S, p;
		int[] t;

		// get total case
		totalCase = scanner.nextInt();

		for (int caseIndex = 1; caseIndex <= totalCase; caseIndex++) {
			// get input
			N = scanner.nextInt();
			S = scanner.nextInt();
			p = scanner.nextInt();
			t = new int[N];
			
			for (int i = 0; i < N; i++) {
				t[i] = scanner.nextInt();
			}
			
			String output = "Case #" + caseIndex + ": " + solve(N, S, p, t);
			System.out.println(output);
			writer.write(output + "\n");
		}
		scanner.close();
		writer.close();
	}
}

/**
 * 
 */

/**
 * @author Ambar
 * Apr 14, 2012
 * 10:34:18 PM
 */
public class QB {

	 int canBeatReqd(int total, int reqdPoints) {
         int result = 0;
         int max;
         if (total % 3 == 2) max = total / 3 + 2;
         else if (total % 3 == 0) max = total / 3 + 1;
         else max = total / 3 + 1;
         if (max >= reqdPoints) result += 2;
         if (total % 3 == 0) max = total / 3;
         else if (total % 3 == 1) max = total / 3 + 1;
         else max = total / 3 + 1;
         if (max >= reqdPoints) result += 1;
         return result;
     }
	 
     static void program() {
         //test(); return;
         int n = Utility.getNoOfTestCases("E:\\Temp\\GCJ2012\\Q2\\B-large.in");
         String[] inputss = Utility.getContents("E:\\Temp\\GCJ2012\\Q2\\B-large.in");
         for (int i = 1; i <= n; ++i) {
//             var inputs = Console.ReadLine().Split().Select(kk => int.Parse(kk)).ToArray();
             String[] inputs2 = inputss[i].split(" ");
             int N = Integer.parseInt(inputs2[0]);
             int S = Integer.parseInt(inputs2[1]);
             int p = Integer.parseInt(inputs2[2]);
//             int N = inputs[0], S=inputs[1], p=inputs[2];
             int beats = 0, beatsIfApart=0;
             for (int j = 3; j < 3 + N; ++j) {
                 int total = Integer.parseInt(inputs2[j]);
                 // only total of 2 onwards can be apart
                 if (total > (p - 1) * 3) beats++;
                 else if (total>1 && total >= (p - 1) * 3 - 1) beatsIfApart++;
             }
             int totalBeats = beats + Math.min(beatsIfApart, S);
             System.out.println("Case #"+(i)+": "+totalBeats);
//             Console.WriteLine("Case #{0}: {1}", i + 1, totalBeats);
         }
     }
     
	public static void main(String[] args) {
		program();
	}

}
