import java.util.List;


public class Case implements Runnable {

	private int id;
	private String output;

	private int n;
	private int s;
	private int p;
	private List<Integer> g;

	public Case(int id) {
		this.id = id;
	}

	public Case(int id, int n, int s, int p, List<Integer> g) {
		super();
		this.id = id;
		this.n = n;
		this.s = s;
		this.p = p;
		this.g = g;
	}

	public String solve() {
		int res = 0;
		for (int googler : g) {
			int b = googler / 3;
			boolean div = googler % 3 == 0;
			if (b >= p) {
				res++;
				continue;
			}
			if (p == b+1) {
				if (div && s > 0 && b > 0) {
					res++;
					s--;
					continue;
				}
				if (!div) {
					res++;
					continue;
				}
			}
			if (p == b+2) {
				if (3*b+2 == googler && s > 0) {
					res++;
					s--;
				}
			}
		}
		return String.valueOf(res);
	}

	@Override
	public void run() {
		output = solve();
	}

	@Override
	public String toString() {
		return "Case #" + id + ": " + output;
	}

}
import java.io.*;
import java.util.*;
import java.util.regex.*;

public class jam02 {

	/**
	 * @param args
	 */
	
	public static void main1(){
	// scalar product problem
	}
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		
		int number_test;
		Scanner sc = new Scanner(System.in);
		number_test = sc.nextInt();
		for(int j=1;j<=number_test;j++) {
			int numOfGooglers = sc.nextInt();
			int numOfSurprises = sc.nextInt();
			int surPrisingNum = sc.nextInt();
			int[] googlers = new int[numOfGooglers];
			for(int i=0;i<numOfGooglers;i++)
			{
				googlers[i] = sc.nextInt();
			}
			System.out.print("Case #" + j + ": ");
			action(surPrisingNum,numOfSurprises,googlers);
//			System.out.println(sum);
		}
	}


	private static void action(int surPrisingNum, int numOfSurprises,
			int[] googlers) {
		// TODO Auto-generated method stub
		// Iterating over the elements in the set
		int finalGuys = 0;
		for(int i=0;i<googlers.length;i++)
		{
			if(googlers[i] >= (surPrisingNum*3)-2)
			{
				finalGuys++;
			}
			else if(numOfSurprises !=0 && googlers[i] !=0 && googlers[i] >= (surPrisingNum*3)-4)
			{
				finalGuys++;
				numOfSurprises--;
			}
		}
		System.out.println(finalGuys);
			
	}
}
