/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Dancing
 * Jason Bradley Nel
 * 16287398
 */
import java.io.*;

public class Dancing {

    public static void main(String[] args) {

        In input = new In("input.txt");
        int T = Integer.parseInt(input.readLine());

        for (int i = 0; i < T; i++) {
            System.out.printf("Case #%d: ", i + 1);
            int N = input.readInt();
            int s = input.readInt();
            int p = input.readInt();
            int c = 0;//counter for >=p cases
            //System.out.printf("N: %d, S: %d, P: %d, R: ", N, s, p);
            
            for (int j = 0; j < N; j++) {
                
                int score = input.readInt();
                int q = score / 3;
                int m = score % 3;
                //System.out.printf("%2d (%d, %d) ", scores[j], q, m);
                                
                switch (m) {
                    case 0:
                        if (q >= p) {
                            c++;
                        } else if (((q + 1) == p) && (s > 0) && (q != 0)) {
                            c++;
                            s--;
                        }
                        break;
                    case 1:
                        if (q >= p) {
                            c++;
                        } else if ((q + 1) == p) {
                            c++;
                        }
                        break;
                    case 2:
                        if (q >= p) {
                            c++;
                        } else if ((q + 1) == p) {
                            c++;
                        } else if (((q + 2) == p) && (s > 0)) {
                            c++;
                            s--;
                        }
                        break;
                }
            }
            //System.out.printf("Best result of %d or higher: ", p);
            System.out.println(c);
        }


    }
}

import java.util.*;
import java.io.*;

public class B {

	public static void main(String[] args) throws Exception {
		BufferedReader in = new BufferedReader(new FileReader(args[0]));
		in.readLine();
		
		String[] segments;
		int[] scores;
		int numCase = 0;
		while (in.ready()) {
			segments = in.readLine().split(" ");
			scores = new int[segments.length - 3];
			for (int i = 0; i < scores.length; ++i) {
				scores[i] = Integer.parseInt(segments[i + 3]);
			}
			solve(++numCase, Integer.parseInt(segments[1]), Integer.parseInt(segments[2]), scores);
		}
	}
	
	private static void solve(int caseNum, int s, int p, int[] scores) {
		int max = 0;
		
		if (p == 0) {
			max = scores.length;
		} else if (p == 1) {
			for (int i = 0; i < scores.length; ++i) {
				if (scores[i] >= 1) {
					++max;
				}
			}
		} else {
			int limit1 = (p - 2) * 3 + 2;
			int limit2 = limit1 + 1;
			
			int needS = 0;
			
			int score;
			for (int i = 0; i < scores.length; ++i) {
				score = scores[i];
				if (score < limit1) {
					continue;
				}
				
				if (score <= limit2) {
					++ needS;
					continue;
				}
				
				++max;
			}
			
			max += Math.min(needS, s);
		}
		
		System.out.printf("Case #%d: %d\n", caseNum, max);
	}
}