package code12.qualification;

import java.io.File;
import java.io.FileWriter;
import java.util.Scanner;

public class B {
	public static String solve(int N, int S, int p, int[] t) {
		
		// 3a 		-> (a, a, a), *(a - 1, a, a + 1)
		// 3a + 1	-> (a, a, a + 1), *(a - 1, a + 1, a + 1)
		// 3a + 2	-> (a, a + 1, a + 1), *(a, a, a + 2)
		
		int numPNoS = 0;
		int numPWithS = 0;
		
		for (int i = 0; i < N; i++) {
			int a = (int)Math.floor(t[i] / 3);
			int r = t[i] % 3;
			
			switch (r) {
			case 0:
				if (a >= p) {
					numPNoS++;
				} else if (a + 1 >= p && a - 1 >= 0) {
					numPWithS++;
				}
				break;
			case 1:
				if (a >= p || a + 1 >= p) {
					numPNoS++;
				}
				break;
			case 2:
				if (a >= p || a + 1 >= p) {
					numPNoS++;
				} else if (a + 2 >= p) {
					numPWithS++;
				}
				break;
			}
		}
		
		return "" + (numPNoS + Math.min(S, numPWithS));
	}

	public static void main(String[] args) throws Exception {
		// file name
		//String fileName = "Sample";
		//String fileName = "B-small";
		String fileName = "B-large";
		
		// file variable
		File inputFile = new File(fileName + ".in");
		File outputFile = new File(fileName + ".out");
		Scanner scanner = new Scanner(inputFile);
		FileWriter writer = new FileWriter(outputFile);

		// problem variable
		int totalCase;
		int N, S, p;
		int[] t;

		// get total case
		totalCase = scanner.nextInt();

		for (int caseIndex = 1; caseIndex <= totalCase; caseIndex++) {
			// get input
			N = scanner.nextInt();
			S = scanner.nextInt();
			p = scanner.nextInt();
			t = new int[N];
			
			for (int i = 0; i < N; i++) {
				t[i] = scanner.nextInt();
			}
			
			String output = "Case #" + caseIndex + ": " + solve(N, S, p, t);
			System.out.println(output);
			writer.write(output + "\n");
		}
		scanner.close();
		writer.close();
	}
}

/**
 * 
 */
package hu.hke.gcj;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.UnsupportedEncodingException;

/**
 * @author katalma
 *
 */
public class DancingWithTheGooglers {

	static DancingWithTheGooglers dwtg = new DancingWithTheGooglers() ;
	/**
	 * @param args
	 */
	public static void main(String[] args) {

		readAndCalculate(args[0], args[1]);
	}

	private static void readAndCalculate(String inputF, String outputF) {
		BufferedReader input = null;
		BufferedWriter output = null;
		try {
			String line = null;
			input =  new BufferedReader(new FileReader(inputF));
			output = new BufferedWriter(new FileWriter(outputF));
			boolean first = true;
			int expectedRows = 0;
			int actualRows = -1;
			while ((( line = input.readLine()) != null) && (actualRows < expectedRows)) {
				System.out.print(actualRows+1);
				System.out.println("----------------------------------------------------");
				if (first) {
					first = false;
					expectedRows = Integer.parseInt(line);
				} else {
					output.write("Case #" +(actualRows+1)+": "+ dwtg.maximumBestResults(line));
					if (actualRows +1 < expectedRows) {
						output.write("\n");
					}
				}
				actualRows++;
			}
			
			input.close();
			output.close();
		} catch (UnsupportedEncodingException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} finally {
		}
		
	}

	private String maximumBestResults(String line) {
		// TODO Auto-generated method stub
		System.out.println(line);
		B actLine = new B(line);
		return actLine.pGooglers();
	}
	
	class B {
		int googlerN;
		int suprs;
		int p;
		Googler[] googlers;
		int pGooglers;
		
		private B() {};
		
		B(String line) {
			String[] tmp = line.split(" ");
			googlerN = Integer.parseInt(tmp[0]);
			suprs = Integer.parseInt(tmp[1]);
			p = Integer.parseInt(tmp[2]);
			googlers = new Googler[googlerN<= tmp.length-3? googlerN : tmp.length-3];
			for (int i = 0; i < googlers.length; i++) {
				googlers[i] = new Googler(Integer.parseInt(tmp[i+3])); 
			}
			pGooglers = 0;
		}

		public String pGooglers() {
			// TODO Auto-generated method stub
			System.out.println("Limit: "+p+" Suprise: "+suprs);
			pGooglers = 0;
			int actSuprs = 0;
			for (int i = 0; i < googlers.length; i++) {
				if (googlers[i].possibleP(p)) {
					System.out.println("Possible: " +googlers[i]);
					pGooglers++;
				} else if (actSuprs< suprs) {
					System.out.println("with suprise?");
					if (googlers[i].possiblePS(p)) {
						System.out.println("Possible with suprise: " +googlers[i]);
						pGooglers++;
						actSuprs++;
					} 
				}
			}
			return Integer.toString(pGooglers);
		}
		
	}

	class Googler {
		int totalCounts;
		int div;
		int mod;
		
		Googler(int i) {
			totalCounts = i;
			div = i/3;
			mod = i%3;
		}

		public boolean possibleP(int p) {
			if (div>=p) {
				return true;
			}
			if ((mod<2 ) &&(div+mod>=p)) {
				return true;
			}
			if ((mod==2 ) && (div+1>=p)&& (totalCounts>1)) {
				return true;
			}
			return false;
		}
		public boolean possiblePS(int p) {
			if (div>=p) {
				return true;
			}
			if (div+mod>=p) {
				return true;
			}
			if ((mod==0 ) && (div+1>=p) && (totalCounts>1)) {
				return true;
			}
			return false;
		}
		public String toString() {
			return "googgler: "+totalCounts+"::"+div+"::"+mod;
		}
	}
}
