import java.io.BufferedReader;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.StringTokenizer;


public class DancingWithTheGooglers {
	public static void main(String[] args) throws IOException {
		BufferedReader f = new BufferedReader (new FileReader("B-small.in"));
		PrintWriter out = new PrintWriter(new FileWriter("B-small.out"));
		
		int t = Integer.parseInt(f.readLine());
		for (int i = 0; i < t; i++){
			int c = 0;
			StringTokenizer st = new StringTokenizer(f.readLine());
			int n = Integer.parseInt(st.nextToken());
			int[] ti = new int[n];
			int s = Integer.parseInt(st.nextToken());
			int p = Integer.parseInt(st.nextToken());
			for (int j = 0; j < n; j ++){
				ti[j] = Integer.parseInt(st.nextToken());
				if (ti[j] % 3 == 0){
					if (ti[j] / 3 >= p)
						c++;
					else if (ti[j] / 3 == (p-1) && s > 0 && ti[j] >= 2){
						s--;
						c++;
					}
				}
				else if (ti[j] % 3 == 1){
					if ((ti[j] / 3) + 1 >= p)
						c++;					
				}
				else{
					if (ti[j] / 3 >= p-1)
						c++;
					else if (ti[j] / 3 == (p-2) && s > 0){
						s--;
						c++;
					}
				}
					
				
			}
			out.println("Case #" + (i+1) + ": " + c);
			
			
		}
		out.close();
		System.exit(0);
		
		
		
	}
}

import java.util.Scanner;
import java.io.*;

public class Dancing {

  public static void main(String[] args) throws FileNotFoundException, IOException {
    Scanner input = new Scanner(new File(args[0]));
    Scanner lin;
    int lines = 0;
    
    if (input.hasNextInt()) {
      lines = input.nextInt();
      input.nextLine();
    }
    
    String nLine;
    
    PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("output.txt")));
    
    int googlers, surprising, p;
    int divThree, rem, cases, surprisingCases, answer;
    int[] points;

    for (int i = 0; i < lines; i++) {
      nLine = input.nextLine();
      lin = new Scanner(nLine);
      out.print("Case #" + (i + 1) + ": ");
      
      googlers = lin.nextInt();
      surprising = lin.nextInt();
      p = lin.nextInt();
      points = new int[googlers];
      for (int j = 0; j < googlers; j++) {
        points[j] = lin.nextInt();
      }
      
      cases = 0;
      surprisingCases = 0;
      
      for (int k = 0; k < googlers; k++) {
        divThree = points[k] / 3;
        rem = points[k] % 3;
        if (rem == 0) {
          if (divThree >= p)
            cases++;
          else if (divThree + 1 >= p && divThree != 0)
            surprisingCases++;
        }
        else if (rem == 1) {
          if (divThree + 1 >= p)
            cases++;
        }
        else if (rem == 2) {
          if (divThree + 1 >= p)
            cases++;
          else if (divThree + 2 >= p)
            surprisingCases++;
        }
      }
      
      if (surprisingCases >= surprising) {
        answer = surprising;
      }
      else {
        answer = surprisingCases;
      }
      answer += cases;
        
      out.println(answer);
    }
    
    out.close();
  
  }

}