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.BufferedInputStream;
import java.io.DataInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.util.HashMap;
import java.util.Map;


public class main {

	/**
	 * @param args
	 */
	@SuppressWarnings("deprecation")
	public static void main(String[] args) {
		long now = System.currentTimeMillis();
		// TODO Auto-generated method stub
		File file = new File("./input.txt");
		FileInputStream fis = null;
		BufferedInputStream bis = null;
		DataInputStream dis = null;
		try
		{
			fis = new FileInputStream(file);
			bis = new BufferedInputStream(fis);
			dis = new DataInputStream(bis);
			int testCaseCount = Integer.parseInt(dis.readLine()), testCase;
			for(testCase = 0; testCase < testCaseCount; testCase ++)
			{
				String[] line = dis.readLine().split(" ");
				int N = Integer.parseInt(line[0])
					, S = Integer.parseInt(line[1])
					, p = Integer.parseInt(line[2])
					, i;
				int[] g = new int[N];
				for(i = 0; i < N; i ++)
				{
					g[i] = Integer.parseInt(line[i+3]);
				}
				// Program
				int found = 0, similar = p + ( 2 * (p-1)), surprise = p + (2 * (p-2));
				if(similar < 0)
				{
					if(p > 0 )
					{
						similar = 1;
					}
					else
					{
						similar = 0;
					}
				}
				if(surprise < 0)
				{
					if(p > 0 )
					{
						surprise = 1;
					}
					else
					{
						surprise = 0;
					}
				}
				for(i = 0; i < N; i ++)
				{
					// Not surprising
					if(g[i] >= similar)
					{
						found ++;
					}
					else if(g[i] >= surprise && S > 0)
					{
						found ++;
						S --;
					}
				}
				System.out.println("Case #" + (testCase + 1) + ": " + found);
			}
			fis.close();
			bis.close();
			dis.close();
		}
		catch(Exception e)
		{
			e.printStackTrace();
		}
	}

}
