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

public class B {

	public static void main(String[] args) throws Exception {
		System.setOut(new PrintStream("out"));

		Scanner s = new Scanner(System.in);
		int T = s.nextInt();
		for (int t = 1; t <= T; t++) {
			int N = s.nextInt();
			int S = s.nextInt();
			int P = s.nextInt();

			int[][] matrix = { { 0, 0, 0 }, { 0, 0, 1 }, { 0, 1, 0 }, { 0, 1, 1 }, { 0, 0, -1 }, { 0, -1, 0 }, { 0, -1, -1 }, { 1, 0, 0 }, { 1, 0, 1 },
					{ 1, 1, 0 }, { 1, 1, 1 }, { -1, 0, 0 }, { -1, 0, -1 }, { -1, -1, 0 }, { -1, -1, -1 } };

			int[][] matrix2 = { { 1, 1, -1 }, { 1, -1, 0 }, { 1, -1, 1 }, { 1, -1, -1 }, { 1, 0, -1 }, { 1, 1, -1 }, { 1, -1, 0 }, { 1, -1, 1 }, { 1, -1, -1 },
					{ 1, 0, -1 }, { 1, 1, -1 }, { 1, -1, 0 }, { 1, -1, 1 }, { 1, -1, -1 } };

			int max = 0;

			for (int n = 0; n < N; n++) {
				int x = s.nextInt();

				boolean ok = false;
				int m = x / 3;
				for (int i = 0; i < matrix.length; i++) {
					int a = m + matrix[i][0];
					int b = m + matrix[i][1];
					int c = m + matrix[i][2];

					if (a == 7 && b == 6 && c == 9)
						continue;

					if (a + b + c == x && a >= 0 && b >= 0 && c >= 0 && a <= 10 && b <= 10 && c <= 10) {
						if (Math.max(a, Math.max(b, c)) >= P) {
							max++;
							ok = true;
							break;
						}
					}
				}

				if (ok == false) {
					m = x / 3 + 1;
					for (int i = 0; i < matrix.length; i++) {
						int a = m + matrix[i][0];
						int b = m + matrix[i][1];
						int c = m + matrix[i][2];

						if (a == 7 && b == 6 && c == 9)
							continue;

						if (a + b + c == x && a >= 0 && b >= 0 && c >= 0 && a <= 10 && b <= 10 && c <= 10) {
							if (Math.max(a, Math.max(b, c)) >= P) {
								max++;
								ok = true;
								break;
							}
						}
					}
				}

				if (ok == false) {
					m = x / 3 - 1;
					for (int i = 0; i < matrix.length; i++) {
						int a = m + matrix[i][0];
						int b = m + matrix[i][1];
						int c = m + matrix[i][2];

						if (a == 7 && b == 6 && c == 9)
							continue;

						if (a + b + c == x && a >= 0 && b >= 0 && c >= 0 && a <= 10 && b <= 10 && c <= 10) {
							if (Math.max(a, Math.max(b, c)) >= P) {
								max++;
								ok = true;
								break;
							}
						}
					}
				}

				if (ok == false && S > 0) {
					m = x / 3;
					for (int i = 0; i < matrix2.length; i++) {
						int a = m + matrix2[i][0];
						int b = m + matrix2[i][1];
						int c = m + matrix2[i][2];

						if (a == 7 && b == 6 && c == 9)
							continue;

						if (a + b + c == x && a >= 0 && b >= 0 && c >= 0 && a <= 10 && b <= 10 && c <= 10) {
							if (Math.max(a, Math.max(b, c)) >= P) {
								max++;
								S--;
								ok = true;
								break;
							}
						}
					}
				}

				if (ok == false && S > 0) {
					m = x / 3 + 1;
					for (int i = 0; i < matrix2.length; i++) {
						int a = m + matrix2[i][0];
						int b = m + matrix2[i][1];
						int c = m + matrix2[i][2];

						if (a == 7 && b == 6 && c == 9)
							continue;

						if (a + b + c == x && a >= 0 && b >= 0 && c >= 0 && a <= 10 && b <= 10 && c <= 10) {
							if (Math.max(a, Math.max(b, c)) >= P) {
								max++;
								S--;
								ok = true;
								break;
							}
						}
					}
				}
				if (ok == false && S > 0) {
					m = x / 3 - 1;
					for (int i = 0; i < matrix2.length; i++) {
						int a = m + matrix2[i][0];
						int b = m + matrix2[i][1];
						int c = m + matrix2[i][2];

						if (a == 7 && b == 6 && c == 9)
							continue;

						if (a + b + c == x && a >= 0 && b >= 0 && c >= 0 && a <= 10 && b <= 10 && c <= 10) {
							if (Math.max(a, Math.max(b, c)) >= P) {
								max++;
								S--;
								ok = true;
								break;
							}
						}
					}
				}
			}

			System.out.println("Case #" + t + ": " + max);
		}

	}
}
