import java.util.*;
public class Test {
  public static void main(String[] args){
    Scanner in = new Scanner(System.in);
    int T = in.nextInt();

    for(int i = 1; i<=T; i++) {
      int n = in.nextInt();
      int s = in.nextInt();
      int p = in.nextInt();
      int result = 0;
      for(int j = 0; j<n; j++){
        int x = canAddUp(in.nextInt(), p);
        if(x == 0) {
          result++;
        } else if (x==1 && s > 0) {
          result++;
          s--;
        }
      }
      System.out.println("Case #"+i+": "+result);
    }
  }

  public static int canAddUp(int sum, int limit) {
    boolean flag = false;
    for(int i = 0; i<=sum; i++) {
      for(int j = 0; i+j <= sum; j++) {
        int k = sum-(i+j);
        int a = Math.abs(i-j);
        int b = Math.abs(i-k);
        int c = Math.abs(j-k);
        if(a > 2 || b > 2 || c> 2){
          continue;
        }

        if (i>=limit || j>=limit || k>=limit) {
          if(a < 2 && b < 2 && c < 2) {
            return 0;
          }else{
            flag = true;
          }
        }
      }
    }
    return (flag) ? 1 : 2;
  }
}

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-large";

	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();
	}
	
}