/**
 * Created by IntelliJ IDEA.
 * User: Administrator
 * Date: 3/3/12
 * Time: 11:00 AM
 * To change this template use File | Settings | File Templates.
 */

import SRMLib.MathLibrary;
import SRMLib.TestSRMLib;
import com.sun.org.apache.bcel.internal.generic.F2D;

import java.io.*;
import java.util.*;
import java.util.zip.Inflater;

public class SRM {
    public static void main(String[] args) throws IOException {
        //TestSRMLib.run();
        codeJam1.main();

        return;
    }
}
class codeJam1 {
    public static void main() throws IOException {
        String inputPath = "E:\\input.txt";
        String outputPath = "E:\\output.txt";
        BufferedReader input = new BufferedReader(new FileReader(inputPath));
        BufferedWriter output = new BufferedWriter(new FileWriter(outputPath));

        String line;
        line = input.readLine();
        int T = Integer.parseInt(line);
        for (int i = 1; i <= T; ++i) {
            line = input.readLine();
            String[] words = line.split(" ");
            int N = Integer.parseInt(words[0]);
            int S = Integer.parseInt(words[1]);
            int p = Integer.parseInt(words[2]);
            int n = 0;
            int res = 0;

            for (int j = 3; j < words.length; ++j) {
                if (p == 0) {
                    res++;
                    continue;
                }

                int t = Integer.parseInt(words[j]);
                if (p == 1) {
                    if (t > 0)
                        res++;
                    continue;
                }
                if (t >= 3 * p - 2)
                    res++;
                else if (t >= 3 * p - 4)
                    n++;
            }

            res += Math.min(n, S);
            output.write("Case #" + i + ": " + res);
            output.newLine();
        }

        input.close();
        output.close();
    }
}

import java.io.*;
import java.util.Arrays;

public class Main{
	
	public static void main(String[] args) throws Exception {
		int t = Integer.parseInt(finB.readLine());
		int test = 1;
		while(test <= t){
			int n = fnextInt();
			int s = fnextInt();
			int p = fnextInt();
			int[] a = new int[n];
			for(int i = 0; i < n; i++){
				a[i] = fnextInt();
			}
			print(n + " " + s + " " + p + " ");
			for(int i = 0; i < n; i++){
				print(a[i] + " ");
			}
			int[] max = new int[n];
			for(int i = 0; i < n; i++){
				if(a[i] / 3 == 0){
					if(p == 2 && a[i] == 2 && s > 0){
						max[i] = a[i];
						s--;
						continue;
					}
					else if(a[i] == 2) max[i] = 1;
					else max[i] = a[i];
					continue;
				}
				if(a[i] % 3 == 0 && a[i] / 3 < p){
					if(s > 0 && a[i] / 3 + 1 == p){
						max[i] = a[i] / 3 + 1;
						s--;
						continue;
					}
				}
				if(a[i] % 3 == 2 && a[i] / 3 + 1 < p){
					if(s > 0 && a[i] / 3 + 2 == p){
						max[i] = a[i] / 3 + 2;
						s--;
						continue;
					}
				}
				max[i] = a[i] % 3 > 0 ? a[i] / 3 + 1 : a[i] / 3;
			}
			int ans = 0;
			for(int i = 0; i < n; i++){
				if(max[i] >= p) ans++;
			}
			fout.println("Case #" + test + ": " + ans);
			println("Case #" + test + ": " + ans);
			test++;
		}
		fout.flush();
	}
		
	private static PrintWriter out;
	private static BufferedReader inB;
	private static BufferedReader finB;
	private static PrintWriter fout;
	
	
	static {
		try {
			finB = new BufferedReader(new InputStreamReader(new FileInputStream("input.in")));
			fout = new PrintWriter(new FileOutputStream("output.txt"));
			out = new PrintWriter(System.out);
			inB = new BufferedReader(new InputStreamReader(System.in));
		} catch(Exception e) {e.printStackTrace();}
	}
	
	private static StreamTokenizer in = new StreamTokenizer(inB);
	private static StreamTokenizer fin = new StreamTokenizer(finB);
	
	private static void exit(Object o) throws Exception {
		out.println(o);
		out.flush();
		System.exit(0);
	}
	private static void println(Object o) throws Exception{
		out.println(o);
		out.flush();
	}
	private static void print(Object o) throws Exception{
		out.print(o);
		out.flush();
	}
	private static int fnextInt() throws Exception {
		fin.nextToken();
		return (int)fin.nval;
	}  
	private static int nextInt() throws Exception {
		in.nextToken();
		return (int)in.nval;
	}  
	private static String nextString() throws Exception {
		in.nextToken();
		return in.sval;        
	}
} 