package com.silverduner.codejam;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.util.HashMap;

public class Dancing {
	public static void main(String[] args) throws Exception {
		File input = new File("B-small-attempt0.in");
		BufferedReader in = new BufferedReader(new FileReader(input));

		File output = new File("1.out");
		BufferedWriter out = new BufferedWriter(new FileWriter(output));

		// parse input
		int N = Integer.parseInt(in.readLine());
		for(int i=0;i<N;i++) {
			String str = in.readLine();
			out.write("Case #"+(i+1)+": ");
			System.out.println("-------");
			String[] words = str.split(" ");
			int n = Integer.parseInt(words[0]);
			int suprise = Integer.parseInt(words[1]);
			int threshold = Integer.parseInt(words[2]);
			int[] scores = new int[n];
			for(int j=0;j<n;j++) {
				scores[j] = Integer.parseInt(words[3+j]);
			}
			int count = 0;
			for(int score : scores) {
				int a,b,c;
				boolean find = false;
				boolean sfind = false;
				for(a = 10; a>=0 && !find; a--) {
					if(3*a-4>score)
						continue;
					for(b = a; b>=0 && b >=a-2 && !find; b--) {
						for(c = b; c>=0 && c >=b-2 && c >=a-2 && !find; c--) {
							System.out.println(a+","+b+","+c);
							if(a+b+c==score) {
								if(a >= threshold) {
									if(a-c <= 1){
										count++;
										find = true;
										System.out.println("find!");
									}
									else if(a-c == 2){
										sfind = true;
										System.out.println("suprise!");
									}
								}
							}
							
						}
					}
				}
				if(!find && sfind && suprise > 0)
				{
					count++;
					suprise --;
				}
			}
			int maxCount = count;
			out.write(maxCount+"\n");
		}
		out.flush();
		out.close();
		in.close();
	}
}

import java.util.Scanner;
class Another{
	private int total, modulo;
	public Another(int a){
		total = a;
		modulo = a % 3;
	}
	public int surprisingScore(){
		if (total < 3){
			return total;
		} else
		if (modulo == 2){
			return (total/3) + 2;
		} else {
			return (total/3) + 1;
		}
	}
	public int notSurprisingScore(){
		if (total < 2){
			return total;
		} else if (total == 2){
			return 1;
		} else
		if (modulo == 0){
			return (total/3);
		} else {
			return (total/3) + 1;
		}
	}
}
class DanceResult{
	private int[] myArray;
	private int arraySize, minimum, numberOfSurprises;
	private int[][] result;
	public DanceResult(int[] anArray, int min, int surprises){
		myArray = anArray;
		minimum = min;
		numberOfSurprises = surprises;
		arraySize = myArray.length;
		result = new int[arraySize][2];
	}
	public void generateScores(){
		for (int i = 0; i < arraySize; i++){
			int value = myArray[i];
			Another checkScore = new Another(value);
			int surprising = checkScore.surprisingScore();
			int notSurprising = checkScore.notSurprisingScore();
			result[i][0] = surprising;
			result[i][1] = notSurprising;
		}
		return;
	}
	public int solve(){
		int countSurprise = 0;
		int countNotSurprise = 0;
		for (int i = 0; i < arraySize; i++){
			if (result[i][0] >= minimum){
				countSurprise++;
			}
			if (result[i][1] >= minimum){
				countNotSurprise++;
			}
		}
		int difference = countSurprise - countNotSurprise;
		if (difference >= numberOfSurprises){
			return countNotSurprise + numberOfSurprises;
		} else
			return countSurprise;
	}
}
public class Dance {

	public static void main(String[] args) {
		int numberOfGooglers, numberOfSurprising, leastScore, numberOfCases, currentCase;
		int[] scores;
		DanceResult myResult;
		Scanner myScanner = new Scanner(System.in);
		numberOfCases = myScanner.nextInt();
		currentCase = 1;
		for (int j = 0; j < numberOfCases; j++){
			numberOfGooglers = myScanner.nextInt();
			numberOfSurprising = myScanner.nextInt();
			leastScore = myScanner.nextInt();
			scores = new int[numberOfGooglers];
			for(int i = 0; i < numberOfGooglers; i++){
				scores[i] = myScanner.nextInt();
			}
			myResult = new DanceResult(scores, leastScore, numberOfSurprising);
			myResult.generateScores();
			System.out.println("Case #" + currentCase + ": " + myResult.solve());
			currentCase++;
		}

		
	}

}
