package com.menzus.gcj._2012.qualification.b;

import com.menzus.gcj.common.InputBlockParser;
import com.menzus.gcj.common.OutputProducer;
import com.menzus.gcj.common.impl.AbstractProcessorFactory;

public class BProcessorFactory extends AbstractProcessorFactory<BInput, BOutputEntry> {
    public BProcessorFactory(String inputFileName) {
	super(inputFileName);
    }

    @Override
    protected InputBlockParser<BInput> createInputBlockParser() {
	return new BInputBlockParser();
    }

    @Override
    protected OutputProducer<BInput, BOutputEntry> createOutputProducer() {
	return new BOutputProducer();
    }
}

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class B {

	public final String INPUT_FILE_NAME = "b_in";
	public final String OUTPUT_FILE_NAME = "b_out";

	int kase = 1;
	int N = 0;
	int T = 0;
	int P = 0;
	int SUR = 0;
	int ans = 0;
	ArrayList<Integer> sums = new ArrayList<Integer>();
	ArrayList<ArrayList<ArrayList<Integer>>> cache = new ArrayList<ArrayList<ArrayList<Integer>>>();
	int[][] memo;

	public ArrayList<ArrayList<Integer>> gen(int sum) {
		ArrayList<ArrayList<Integer>> ans = new ArrayList<ArrayList<Integer>>();

		for (int i = 0; i <= 10; i++) {
			for (int j = 0; j <= 10; j++) {
				if (Math.abs(j - i) > 2)
					continue;
				for (int k = 0; k <= 10; k++) {
					if (Math.abs(i - k) > 2) continue;
					if (Math.abs(j - k) > 2) continue;
					if (i + j + k != sum) continue;
					ArrayList<Integer> v = new ArrayList<Integer>();
					v.add(i); v.add(j); v.add(k); ans.add(v);
				}
			}
		}

		return ans;
	}

	public boolean isSur(ArrayList<Integer> v) {
		int a = v.get(0); int b = v.get(1); int c = v.get(2);
		if (Math.abs(a - b) == 2) return true;
		if (Math.abs(a - c) == 2) return true;
		if (Math.abs(b - c) == 2) return true;
		return false;
	}
	
	public boolean isP(ArrayList<Integer> v) {
		int a = v.get(0); int b = v.get(1); int c = v.get(2);
		if (a >= P) return true;
		if (b >= P) return true;
		if (c >= P) return true;
		return false;
	}
//
//	public void solve(int count, int sur, int index) {
//		if (index == -1) {
//			if (sur == 0)
//				ans = Math.max(ans, count);
//			return;
//		}
//		if (sur < 0)
//			return;
//		ArrayList<ArrayList<Integer>> v = cache.get(sums.get(index));
//
//		for (int i = 0; i < v.size(); i++) {
//			boolean surprize = isSur(v.get(i));
//			if (isP(v.get(i))){
//				if (surprize)
//					solve(count + 1, sur - 1, index - 1);
//				else
//					solve(count + 1, sur, index - 1);
//			}else{ 
//				if (surprize)
//					solve(count, sur - 1, index - 1);
//				else
//					solve(count, sur, index - 1);
//			}
//		}
//	}

	public int solve2(int sur, int index) {
		if (index == -1) {
			if (sur == 0)
				return 0;
			return -1;
		}
		ArrayList<ArrayList<Integer>> v = cache.get(sums.get(index));

		int max = 0;
		for (int i = 0; i < v.size(); i++) {
			boolean surprize = isSur(v.get(i));
			int newsur= sur;
			if (surprize)
				newsur -= 1;
			if (newsur  < 0)
				continue;
			if (isP(v.get(i))) {
				if (index == 0 || memo[newsur][index-1] == -1)
					max = Math.max(max, solve2(newsur, index - 1) + 1);
				else
					max = Math.max(max, memo[newsur][index-1]+ 1);
			} else {
				if (index == 0 || memo[newsur][index-1] == -1)
					max = Math.max(max, solve2(newsur, index - 1));
				else
					max = Math.max(max, memo[newsur][index-1]);
			}
		}
		memo[sur][index] = max;
		return max;
	}

	public void run() throws IOException {
		Scanner s = new Scanner(new File(INPUT_FILE_NAME));
		// BufferedReader br = new BufferedReader(new
		// FileReader(INPUT_FILE_NAME));
		PrintWriter pw = new PrintWriter(new FileWriter(OUTPUT_FILE_NAME));
		// PrintWriter pw = new PrintWriter(new OutputStreamWriter(System.out));

		for (int i = 0; i <= 30; i++)
			cache.add(gen(i));

		T = s.nextInt();
		while (T-- > 0) {
			ans = 0;
			sums = new ArrayList<Integer>();
			memo = new int[101][101];
			for (int i = 0; i < 101; i++)
				Arrays.fill(memo[i], -1);
			
			N = s.nextInt();
			SUR = s.nextInt();
			P = s.nextInt();
			for (int i = 0; i < N; i++)
				sums.add(s.nextInt());
			//solve(0, SUR, N - 1);
			ans = solve2(SUR, N - 1);
			pw.println("Case #" + kase + ": " + ans);
			kase++;
		}

		pw.close();
		s.close();
	}

	public static void main(String[] args) throws IOException {
		(new B()).run();
	}

}
