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

public class Solution {


	private StringTokenizer st;
	private BufferedReader in;
	private PrintWriter out;
	
//	final String file = "sample";
	final String file = "B-small-attempt1";

	public void solve() throws IOException {
		int tests = nextInt();
		for (int test = 0; test < tests; ++test) {
			int n = nextInt();
			int k = nextInt();
			int p = nextInt();
			int[] d = new int[k + 1];
			Arrays.fill(d, -1000000000);
			d[0] = 0;
			for (int i = 0; i < n; ++i) {
				int[] d1 = new int[k + 1];
				int a = nextInt();
				int val0 = -1000000000, val1 = -1000000000;
				for (int u = 0; u <= 10 && 3 * u <= a; ++u) {
					for (int v = u; v <= 10 && v <= u + 2 && u + 2 * v <= a; ++v) {
						int w = a - u - v;
						if (w <= u + 2 && w >= 0 && w <= 10) {
							if (w - u <= 1) {
								val0 = Math.max(val0, w >= p ? 1 : 0);
							} else {
								val1 = Math.max(val1, w >= p ? 1 : 0);
							}
						}
					}
				}
				for (int j = 0; j <= k; ++j) {
					d1[j] = d[j] == -1000000000 ? -1000000000 : d[j] + val0;
				}
				for (int j = 0; j < k; ++j) {
					if (d[j] != -1000000000) {
						d1[j + 1] = Math.max(d1[j + 1], d[j] + val1);
					}
				}
				d = d1;
			}
			out.printf("Case #%d: %d%n", test + 1, d[k]);
		}
	}

	public void run() throws IOException {
		in = new BufferedReader(new FileReader(file + ".in"));
		out = new PrintWriter(file + ".out");
		eat("");
		
		solve();
		
		out.close();
	}
	
	void eat(String s) {
		st = new StringTokenizer(s);
	}
	
	String next() throws IOException {
		while (!st.hasMoreTokens()) {
			String line = in.readLine();
			if (line == null) {
				return null;
			}
			eat(line);
		}
		return st.nextToken();
	}
	
	int nextInt() throws IOException {
		return Integer.parseInt(next());
	}
	
	long nextLong() throws IOException {
		return Long.parseLong(next());
	}
	
	double nextDouble() throws IOException {
		return Double.parseDouble(next());
	}
	
	public static void main(String[] args) throws IOException {
		Locale.setDefault(Locale.US);
		new Solution().run();
	}
	
}