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.util.Scanner;

/*
 * el resto es 0 --> puede ser caso especial y no
 * 		15 --> 5 5 5 Ã³ 4 5 6
 * el resto es 1 --> puede ser caso especial y no
 * 		16 --> 4 6 6 Ã³ 5 5 6
 * el resto es 2 --> puede ser caso especial y no
 * 		17 --> 5 7 7 Ã³ 5 6 6 
 */

public class B {
	public static void main(String[] args) {
		final int JUDGES = 3;
		final int MINSCORE = 0;
		Scanner in = new Scanner(System.in);
		int t = in.nextInt();
		for (int i = 1; i <= t; i++) {
			int n = in.nextInt();
			int s = in.nextInt();
			int p = in.nextInt();
			int success = 0;
			for (int j = 0; j < n; j++) {
				int totalScores = in.nextInt();
				int score = totalScores / JUDGES;
				int rest = totalScores % JUDGES;
				if (totalScores==MINSCORE) {
					if (p==MINSCORE) { 
						success++;
					}
				} else if (score >= p || (score+1>=p && rest>=1)) {
					success++;
				} else if (score + 1 >= p && rest < 1 && s > 0) {
					success++;
					s--;
				} else if (score + 2 >= p && rest == 2 && s > 0) {
					success++;
					s--;
				}
			}
			System.out.format("Case #%d: %d\n", i, success);
		}
	}
}