import java.io.BufferedReader;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;

public class CodeJam {

//	public static final String INPUT_FILE_PATH = "D://CodeJamInput.txt";
	public static final String INPUT_FILE_PATH = "D://B-large.in";
	public static final String OUTPUT_FILE_PATH = "D://CodeJamOutput.txt";

	public static List<String> readInput() {
		List<String> list = new ArrayList<String>();
		try {
			BufferedReader input = new BufferedReader(new FileReader(
					INPUT_FILE_PATH));
			try {
				String line = null;

				while ((line = input.readLine()) != null) {
					list.add(line);
				}
			} finally {
				input.close();
			}
		} catch (IOException ex) {
			ex.printStackTrace();
		}
		
		return list;
	}

	public static void writeOutput(List<String> output) {
		PrintWriter writer = null;
		try {
			writer = new PrintWriter(new FileWriter(OUTPUT_FILE_PATH));
			for (String line : output) {
				writer.println(line);
			}
			writer.flush();
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			if (writer != null)
				writer.close();
		}
	}
	
	public static void main(String[] args) {
		List<DanceFloor> danceFloors = DanceFloor.parseFromFile(CodeJam.readInput());
		List<String> output = new ArrayList<String>();

		for(int i = 0; i < danceFloors.size(); i++) {
			System.out.println(danceFloors.get(i));
			String line = "";
			line += "Case #" + (i + 1) + ": " + danceFloors.get(i).calculate();
			output.add(line);
		}
		
		CodeJam.writeOutput(output);
	}
}

class DanceFloor {

	private List<Integer> tripletsTotalCounts;
	private int surpriseCount;
	private int targetScore;
	private int dancersCount;

	public DanceFloor(List<Integer> tripletsTotalCounts, int surpriseCount,
			int targetScore, int dancersCount) {
		this.tripletsTotalCounts = tripletsTotalCounts;
		this.surpriseCount = surpriseCount;
		this.targetScore = targetScore;
		this.dancersCount = dancersCount;
	}

	public int calculate() {
		int result = 0;
		
		if (targetScore == 0) return dancersCount;
		
		for (int i = 0; i < tripletsTotalCounts.size(); i++) {
			int total = tripletsTotalCounts.get(i);

			if (total < (targetScore * 3 - 4)) {
				tripletsTotalCounts.remove(i--);
			} else if (total == 0) {
				tripletsTotalCounts.remove(i--);
			}
		}
		
		for (int i = 0; i < tripletsTotalCounts.size(); i++) {
			int total = tripletsTotalCounts.get(i);

			if ((surpriseCount > 0) && (total == targetScore * 3 - 4)) {
				result++;
				surpriseCount--;
				tripletsTotalCounts.remove(i--);
			} else if ((surpriseCount == 0) && (total == targetScore * 3 - 4)) {
				tripletsTotalCounts.remove(i--);
			}
		}
		
		for (int i = 0; i < tripletsTotalCounts.size(); i++) {
			int total = tripletsTotalCounts.get(i);

			if ((surpriseCount > 0) && (total == targetScore * 3 - 3)) {
				result++;
				surpriseCount--;
				tripletsTotalCounts.remove(i--);
			} else if ((surpriseCount == 0) && (total == targetScore * 3 - 3)) {
				tripletsTotalCounts.remove(i--);
			}
		}
		
		result += tripletsTotalCounts.size();
		
		return result;
	}

	public static List<DanceFloor> parseFromFile(List<String> readInput) {
		List<DanceFloor> result = new ArrayList<DanceFloor>();
		int testCaseCount = Integer.parseInt(readInput.get(0));

		for (int i = 0; i < testCaseCount; i++) {
			String line[] = readInput.get(i + 1).split(" ");

			List<Integer> totalCounts = new ArrayList<Integer>();
			for (int j = 0; j < Integer.parseInt(line[0]); j++) {
				totalCounts.add(Integer.parseInt(line[3 + j]));
			}

			result.add(new DanceFloor(totalCounts, Integer.parseInt(line[1]),
					Integer.parseInt(line[2]), Integer.parseInt(line[0])));
		}

		return result;
	}

	@Override
	public String toString() {
		return "dancersCount = " + dancersCount + "; surpriseCount = " + surpriseCount 
								 + "; targetScore = " + targetScore + "; tripletsTotalCounts" 
								 + tripletsTotalCounts.toString();
	}
}


package Qual;
import java.io.*;
import java.math.*;
import java.util.*;


public class B {
	static void start() throws IOException {
		new B().run1();
	}
	
	private final String dir = "D:\\contest\\gcj\\2012\\" + getClass().getPackage().toString().split(" ")[1] + "\\" + getClass().getSimpleName();
//	private final String inputFileName = "sample.txt";
	private final String inputFileName = "B-large.in";
	private final String outputFileName = "res.txt";
	

	void run() throws IOException {
		int T = IOFast.nextInt();
		while(T-- != 0) {
			final int n = IOFast.nextInt();
			int S = IOFast.nextInt();
			final int p = IOFast.nextInt();
			int res = 0;
			for(int i = 0; i < n; i++) {
				final int x = IOFast.nextInt();
				if((x + 2) / 3 >= p) {
					res++;
				} else if(S > 0 && x != 0) {
					if(x % 3 != 1 && (x + 2) / 3 + 1 >= p) {
						res++;
						S--;
					}
				}
			}
			printCase();
			IOFast.out.println(res);
		}
	}

	void run1() throws IOException {
		IOFast.setReader(new FileReader(dir + "\\" + inputFileName));
		IOFast.setWriter(new FileWriter(dir + "\\" + outputFileName));
		run();
	}
	
	private static int CASE;
	private static void printCase() {
		IOFast.out.print("Case #" + ++CASE + ": ");
	}
	
	public static void main(String[] args) throws IOException {
		start();
		IOFast.out.flush();
		IOFast.in.close();
		IOFast.out.close();
	}

	static
	public class IOFast {
		private static BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		private static PrintWriter out = new PrintWriter(System.out);

		//	private static final int BUFFER_SIZE = 50 * 200000;
		private static final StringBuilder buf = new StringBuilder();
		private static boolean[] isDigit = new boolean[256];
		private static boolean[] isSpace = new boolean[256];

		static {
			for(int i = 0; i < 10; i++) {
				isDigit['0' + i] = true;
			}
			isDigit['-'] = true;
			isSpace[' '] = isSpace['\r'] = isSpace['\n'] = isSpace['\t'] = true;
		}

		static boolean endInput;
		
		public static void setReader(Reader r) { in = new BufferedReader(r); }
		public static void setWriter(Writer w) { out = new PrintWriter(w); }

		private static int nextInt() throws IOException {
			boolean plus = false;
			int ret = 0;
			while(true) {
				final int c = in.read();

				if(c == -1) {
					endInput = true;
					return Integer.MIN_VALUE;
				}

				if(isDigit[c]) {
					if(c != '-') {
						plus = true;
						ret = c - '0';
					}
					break;
				}
			}

			while(true) {
				final int c = in.read();
				if(c == -1 || !isDigit[c]) {
					break;
				}
				ret = ret * 10 + c - '0';
			}

			return plus ? ret : -ret;
		}

		private static long nextLong() throws IOException {
			boolean plus = false;
			long ret = 0;
			while(true) {
				final int c = in.read();

				if(c == -1) {
					endInput = true;
					return Integer.MIN_VALUE;
				}

				if(isDigit[c]) {
					if(c != '-') {
						plus = true;
						ret = c - '0';
					}
					break;
				}
			}

			while(true) {
				final int c = in.read();
				if(c == -1 || !isDigit[c]) {
					break;
				}
				ret = ret * 10 + c - '0';
			}

			return plus ? ret : -ret;
		}



		private static String next() throws IOException {
			buf.setLength(0);

			while(true) {
				final int c = in.read();

				if(c == -1) {
					endInput = true;
					return "-1";
				}

				if(!isSpace[c]) {
					buf.append((char)c);
					break;
				}
			}

			while(true) {
				final int c = in.read();

				if(c == -1 || isSpace[c]) {
					break;
				}
				buf.append((char)c);
			}

			return buf.toString();
		}

		private static double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

	}
}
