/**
 * 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.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;


public class Q2 {
	public static Problem[] probs;

	static class Problem {
		public int N;
		public int S;
		public int p;
		public int[] t;
	}
			
	public static void main(String[] args) {
		String inputFile = args[0];
		parseFile(inputFile);
		try {
			BufferedWriter bw = new BufferedWriter(new FileWriter(inputFile + ".out"));
			for (int i=0; i<probs.length; i++) {
				String output = solveProblem(probs[i]);
				bw.write("Case #" + (i+1) + ": " + output + "\n");
			}
			bw.flush();
			bw.close();
		} catch (IOException ex) {
			ex.printStackTrace();
		}
	}
			
	private static String solveProblem(Problem p) {
		int count = 0;
		if (p.p==0) {
			count = p.N;
		} else if (p.p==1) {
			for (int i=0; i<p.N; i++) {
				if (p.t[i]>0) {
					count++;
				}
			}
		} else {
			int minWithS = 3*p.p-4;
			int min = 3*p.p-2;
			int maybe = 0;
			for (int i=0; i<p.N; i++) {
				if (p.t[i]>=min) {
					count++;
				} else if (p.t[i]>=minWithS) {
					maybe++;
				}
			}
			count += Math.min(maybe, p.S);
		}
		return "" + count;
	}

	public static void parseFile(String inputFile) {
		BufferedReader br;
		try {
			br = new BufferedReader(new FileReader(inputFile));
			String line = br.readLine();
			probs = new Problem[Integer.parseInt(line)];
			line = br.readLine();
			for (int i=0; i<probs.length; i++) {
				probs[i] = new Problem();
				String[] pieces = line.split(" ");
				probs[i].N = Integer.parseInt(pieces[0]);
				probs[i].S = Integer.parseInt(pieces[1]);
				probs[i].p = Integer.parseInt(pieces[2]);
				probs[i].t = new int[probs[i].N];
				for (int j=0; j<probs[i].N; j++) {
					probs[i].t[j] = Integer.parseInt(pieces[3+j]);
				}
				line = br.readLine();
			}
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}
