/**
 * 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.*;

public class qua1 {
	public static int[] factorize(int i) {
		int[] re = new int[3];
		if(i==0)
			for(int ind=0; ind<3; ind++) {
				re[ind] = 0;
			}
		else {
			int temp = i / 3;
			temp++;
			for(int ind=0; ind<3; ind++) {
				re[ind] = temp;
			}
			int diff = temp * 3 - i;
			for(int ind=0; ind<diff; ind++) {
				re[ind] = re[ind] - 1;
			}
		}
		return re;
	}
	public static int[] surp(int[] arr, int l) {
		int[] re = new int[3];
		int id = 0;
		int judge = 0;
		int judge2 = 0;
		for(int ind=0; ind<3; ind++) {
			if(arr[ind]==l-1 && judge==0) {
				re[id] = l;
				judge = 1;
				id++;
			}
			else if(arr[ind]!=l-2 && judge2==0) {
				re[id] = arr[ind] - 1;
				judge2 = 1;
				id++;
			}
			else {
				re[id] = arr[ind];
				id++;
			}
		}
		return re;
	}
	public static void main(String[] args) throws IOException {
		File f = new File(".");
		File path = new File(f.getCanonicalPath()+"/src/"+"B-small-attempt2.in");
		try {
			BufferedReader buf = new BufferedReader(new FileReader(path));
			int T = Integer.parseInt(buf.readLine());
			int[] arr = new int[100];
			String str = null;
			for(int i=0;i<T;i++) {
				int[] info = new int[3];
				str = buf.readLine();
				String[] dat = str.split(" ");
				for(int ii=0;ii<3;ii++) {
					info[ii] = Integer.parseInt(dat[ii]);
				}
				int res = 0;
				int iter = info[1];
				for(int ii=0;ii<info[0];ii++) {
					int sign = 0;
					int diff2 = 0;
					arr[ii] = Integer.parseInt(dat[ii+3]);
					int[] t = factorize(arr[ii]);
					for(int iind=0;iind<3;iind++) {
						//System.out.println(t[iind]);
						if(t[iind]==info[2]-2)
							diff2++;
					}
					for(int ind=0;ind<3;ind++) {
						if(t[ind]>=info[2])
							sign = 1;
					}
					for(int ind=0;ind<3;ind++) {
						if(sign==0 && t[ind]==info[2]-1 && iter!=0 && t[ind]!=0 && diff2!=2) {
							sign = 1;
							iter--;
						}
					}
					//System.out.println(sign);
					if(sign==1)
						res++;
				}
				int line = i+1;
				System.out.println("Case #" + line + ": " + res);
			}
		} catch (FileNotFoundException e1) {
			e1.printStackTrace();
		}	
	}
}
