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();
	}
}

import java.io.File;
import java.lang.StringBuilder;
import java.util.Scanner;
import java.io.FileWriter;
import java.util.ArrayList;
import java.lang.Math;
import java.util.Collections;

public class DWTG {
	
	public static void main(String[] args) throws Exception{
		File input = new File("B-large.in");
		File output = new File("output.out");
		FileWriter fw = new FileWriter(output);
		Scanner s = new Scanner(input);
		
		int numloops = s.nextInt();
		StringBuilder sb = new StringBuilder();
		
		for(int n=0; n<numloops; n++){
			sb.append("Case #" + (n+1) + ": ");
			//System.out.println("Case: " + (n+1));
			int numGooglers = s.nextInt();
			int numSurprises = s.nextInt();
			int minscore = s.nextInt();
			int maxwithscore = 0;
			
			ArrayList<Integer> al = new ArrayList<Integer>();
			
			for(int i=0; i<numGooglers; i++){
				int curnum = s.nextInt();
				
				//System.out.println("Curnum: "+curnum+" ceil: "+Math.ceil(((float)curnum)/3));
				if(Math.ceil(((float)curnum)/3) >= minscore){
					//System.out.println("Added "+Math.ceil(((float)curnum)/3)+" "+minscore);
					maxwithscore++;
					continue;
				}
				
				if(curnum == 0)
					continue;
				
				if((int) Math.ceil(((float)curnum)/3) == curnum/3){
					al.add( (int) Math.ceil(((float)curnum)/3) +1);
					//System.out.println((int) Math.ceil(((float)curnum)/3) +1);
				} else{
					al.add( (int) Math.ceil(((float)curnum)/3));
					//System.out.println( Math.ceil(((float)curnum)/3));
				}
			}
			
			Collections.sort(al);
			Collections.reverse(al);
			
			int i=numSurprises;
			
			while(i>0 && !al.isEmpty()){
				int curnum = al.get(0);
				
				curnum++;
				
				//System.out.println(curnum + " " +minscore);
				
				if(curnum >= minscore){
					maxwithscore++;
				}
				
				al.remove(0);
				i--;
			}
			
			sb.append(maxwithscore + "\n");
		}
		
		fw.write(sb.toString());
		//System.out.println(sb.toString());
		fw.close();
	}
}
