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.ArrayList;

public class DancingWG{
	public static void main(String[] args){
		ArrayList<String> inputs = IOGoogleCodeJam.fileInput(args[0]);
		ArrayList<String> outputs= new ArrayList<String>();
		int lines=Integer.parseInt(inputs.get(0));
		for(int i=1;i<=lines;i++){
			outputs.add(processData(inputs.get(i)));
		}
		IOGoogleCodeJam.resultsOutput(outputs,1);
	}

	public static String processData(String s){
		String aux[] = s.split(" ");
		int N = Integer.parseInt(aux[0]);
		int S = Integer.parseInt(aux[1]);
		int p = Integer.parseInt(aux[2]);
		int c = 0; //count googlers
		for(int i=3;i<aux.length;i++){
			int x = Integer.parseInt(aux[i]);
			int y = 0;
			switch(x%3){
				case 0: y=x/3;
					if(y>=p){
						c++;
					}else if(y>0){//if 0 reach here, it doesn't count
						y=(x+3)/3;
						if(y<=10 && y>=p && S>0){
							c++;
							S--;
						}
					}
					break;
				case 1: y=(x+2)/3;
					if(y>=p){
						c++;//I dont care if there's a surprise here
					}
					break;
				case 2: y=(x+1)/3;
					if(y>=p){
                                        	c++;
                                        }else{
                                                y=(x+4)/3;
                                                if(y<=10 && y>=p && S>0){
                                                	c++;
                                                        S--;
                                                }
                                        }
					break;
			}
		}
		return String.valueOf(c);
	}
}
