package code12.qualification;

import java.io.File;
import java.io.FileWriter;
import java.util.Scanner;

public class B {
	public static String solve(int N, int S, int p, int[] t) {
		
		// 3a 		-> (a, a, a), *(a - 1, a, a + 1)
		// 3a + 1	-> (a, a, a + 1), *(a - 1, a + 1, a + 1)
		// 3a + 2	-> (a, a + 1, a + 1), *(a, a, a + 2)
		
		int numPNoS = 0;
		int numPWithS = 0;
		
		for (int i = 0; i < N; i++) {
			int a = (int)Math.floor(t[i] / 3);
			int r = t[i] % 3;
			
			switch (r) {
			case 0:
				if (a >= p) {
					numPNoS++;
				} else if (a + 1 >= p && a - 1 >= 0) {
					numPWithS++;
				}
				break;
			case 1:
				if (a >= p || a + 1 >= p) {
					numPNoS++;
				}
				break;
			case 2:
				if (a >= p || a + 1 >= p) {
					numPNoS++;
				} else if (a + 2 >= p) {
					numPWithS++;
				}
				break;
			}
		}
		
		return "" + (numPNoS + Math.min(S, numPWithS));
	}

	public static void main(String[] args) throws Exception {
		// file name
		//String fileName = "Sample";
		//String fileName = "B-small";
		String fileName = "B-large";
		
		// file variable
		File inputFile = new File(fileName + ".in");
		File outputFile = new File(fileName + ".out");
		Scanner scanner = new Scanner(inputFile);
		FileWriter writer = new FileWriter(outputFile);

		// problem variable
		int totalCase;
		int N, S, p;
		int[] t;

		// get total case
		totalCase = scanner.nextInt();

		for (int caseIndex = 1; caseIndex <= totalCase; caseIndex++) {
			// get input
			N = scanner.nextInt();
			S = scanner.nextInt();
			p = scanner.nextInt();
			t = new int[N];
			
			for (int i = 0; i < N; i++) {
				t[i] = scanner.nextInt();
			}
			
			String output = "Case #" + caseIndex + ": " + solve(N, S, p, t);
			System.out.println(output);
			writer.write(output + "\n");
		}
		scanner.close();
		writer.close();
	}
}

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;

/**
 *
 * @author akila
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws FileNotFoundException, IOException {
        // TODO code application logic here
        ArrayList<String> testCases = new ArrayList<String>();
        boolean isCaseNo = true;
        int testCount = 0;
        FileReader fr = new FileReader("B-large.in");
        BufferedReader br = new BufferedReader(fr);
        String s;

        while ((s = br.readLine()) != null) {
            if (isCaseNo) {
                testCount = Integer.parseInt(s);
                isCaseNo = false;
            } else {
                testCases.add(s);
            }
        }
        fr.close();
        Solve(testCount, testCases);
    }

    public static void Solve(int testCount, ArrayList<String> testCases) throws IOException {
        

        FileWriter fstream = new FileWriter("out.txt");
        BufferedWriter out = new BufferedWriter(fstream);

        for (int i = 0; i < testCount; i++) {
            ArrayList<Googler> googlers = new ArrayList<Googler>();
            String s = testCases.get(i);
            String[] ar = s.split(" ");

            int noOfGooglers = 0, sup = 0, min = -1, count = 0;
            noOfGooglers = Integer.parseInt(ar[0]);
            sup = Integer.parseInt(ar[1]);
            min = Integer.parseInt(ar[2]);

            for (int j = 3; j < noOfGooglers + 3; j++) {
                Googler g = new Googler();
                googlers.add(g);
                for (int a = 0; a <= 10; a++) {
                    if (a > Integer.parseInt(ar[j])) {
                        break;
                    }
                    for (int b = 0; b <= 10; b++) {
                        if (a + b > Integer.parseInt(ar[j])) {
                            break;
                        }
                        for (int c = 0; c <= 10; c++) {
                            if (a + b + c == Integer.parseInt(ar[j])) {
                                if ((Math.abs(a - b) <= 2)
                                        && (Math.abs(a - c) <= 2)
                                        && (Math.abs(b - c) <= 2)) {
                                    if ((Math.abs(a - b) == 2)
                                        || (Math.abs(a - c) == 2)
                                        || (Math.abs(b - c) == 2)) {

                                        Scores sc = new Scores();
                                        sc.A = a;
                                        sc.B = b;
                                        sc.C = c;
                                        g.sup.add(sc);
                                        g.hasSup = true;
                                        
                                    } else {
                                        Scores sc = new Scores();
                                        sc.A = a;
                                        sc.B = b;
                                        sc.C = c;
                                        g.normal.add(sc);
                                    }
                                }
                            } else if (a + b + c > Integer.parseInt(ar[j])) {
                                break;
                            }
                        }
                    }
                }
            }
            ArrayList<Googler> removed = new ArrayList<Googler>();
            for (int j = 0; j < googlers.size(); j++) {
                Googler googler = googlers.get(j);
                if (googler.hasSup && googler.normal.isEmpty() && sup > 0) {
                    if (googler.hasMinInSup(min)) {
                        count++;   
                    }
                    sup--;
                    removed.add(googler);
                }
            }
            googlers.removeAll(removed);
            
            for (int j = 0; j < googlers.size(); j++) {
                Googler googler = googlers.get(j);
                if (googler.hasMinInNorm(min)) {
                    count++;
                } else if (sup > 0 && googler.hasMinInSup(min)) {
                    count++;
                    sup--;
                }
            }

            out.write("Case #" + (i + 1) + ": " + count + "\n");
        }
        out.close();
    }
}

class Scores {
    public int A = -1, B = -1, C = -1;

    public boolean hasMin(int min) {
        return A >= min || B >= min || C >= min;
    }
}

class Googler {

    public ArrayList<Scores> normal = new ArrayList<Scores>();
    public ArrayList<Scores> sup = new ArrayList<Scores>();
    public boolean hasSup = false;

    public boolean hasMinInSup(int min) {
        for (int i = 0; i < sup.size(); i++) {
            if (sup.get(i).hasMin(min))
                return true;
        }
        return false;
    }

    public boolean hasMinInNorm(int min) {
        for (int i = 0; i < normal.size(); i++) {
            if (normal.get(i).hasMin(min))
                return true;
        }
        return false;
    }
}
