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

public class Q2 {
    public static void main(String[] args) {
        Q2 q = new Q2();
        //q.test();
        //q.answerSmall();
        q.answerLarge();
    }
    
    public void answerSmall(){
        read("B-small-attempt0.IN", "Q2_small_output.txt");
    }
    
    public void answerLarge(){
        read("B-large.IN", "Q2_large_output.txt");
    }
    
    public void test(){
        read("Test2_input.txt", "Test2_output.txt");
    }
    
    public void read(String readFrom, String writeTo){
        try{
            Scanner in = new Scanner(new File(readFrom));
            File f = new File(writeTo);
            FileWriter fw = new FileWriter(f);
            int T = Integer.parseInt(in.nextLine());
            int N,S,p, max, average, remainder, score;
            String[] scores;
            String answer;
            
            for(int i = 1; i <= T; i++) {
                scores = in.nextLine().split(" ");
                N = Integer.parseInt(scores[0]);
                S = Integer.parseInt(scores[1]);
                p = Integer.parseInt(scores[2]);
                max = 0;
                for(int a = 3; a < N + 3; a++) {
                    score = Integer.parseInt(scores[a]);
                    average = score / 3;
                    remainder = score % 3;
                    
                    if(average >= p) {
                        max++;
                    }else if(remainder >= 1 && average + 1 >= p) {
                        max++;
                    }else if(remainder == 2 && average + 2 >= p){
                        if(S > 0){
                            S--;
                            max++;
                        }
                    }else if(remainder == 0 && average - 1 >= 0 && average + 1 >= p) {
                        if(S > 0){
                            S--;
                            max++;
                        }
                    }
                }
                answer = "" + max;
                if(i + 1 <= T)
                    answer += "\r\n";
                fw.write("Case #" + i + ": " + answer);
                
            }
            
            
            fw.close();
        }catch(Exception ex) {
            System.out.println(ex);
        }
    }
}
