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

import java.util.*;
import static java.lang.Math.*;

public class Bsmall {
	public static void main(String[] args){
		Scanner input = new Scanner(System.in);

		//````````````````````````````````````````````````````````````````````
		// Read in how many cases there will be, and print a new line
		int T = input.nextInt();
		input.skip("\n");
		System.out.println();

		//```````````````````````````````````````````````````````````````````
		// For each line calculate max number of googlers with score p
		for(int caseNumber = 1; caseNumber <= T; caseNumber++){
			// Read in N, the number of Googlers
			int N = input.nextInt();

			//Read in S, the number of surprising triplets
			int S = input.nextInt();

			// Read in p
			int p = input. nextInt();

			// Read in the next N integers and count how many googlers have a best
			// result of at least p
			int count = 0;
			for (int i =0; i < N; i++) {
				int totalValue = input.nextInt();
				int j = totalValue / 3;
				int k = (totalValue - j) / 2;
				int l = totalValue - (j + k);

				// Test to see if l >= p
				// If not, see if it can be made into a special triplet with l < p
				if(l >= p){
					count += 1;
					continue;
				}
				else if (S > 0) {
					int a = j - 1;
					int b = l + 1;
					if (a >= 0 && b >= 0 && a <= 10 && b <= 10 && b - a < 3 && b >= p) {
						count += 1;
						S = S -1;
						continue;
					}
					a = k - 1;
					b = l + 1;
					if (a >= 0 && b >= 0 && a <= 10 && b <= 10 && b - a < 3 && b >= p) {
						count += 1;
						S = S -1;
						continue;
					}
				}
			}

			// Print results
			System.out.format("Case #%d: %d\n", caseNumber, count);
		}
	}
}
