import java.io.*;
import java.math.*;
import java.util.*;
import java.text.*;

public class b {
    public static void main(String[] args) {
        Scanner sc = new Scanner(new BufferedInputStream(System.in));

        int T = sc.nextInt();

        for (int casenumber = 1; casenumber <= T; ++casenumber) {

            int n = sc.nextInt();
            int s = sc.nextInt();
            int p = sc.nextInt();

            int[] ts = new int[n];
            for (int i = 0; i < n; ++i)
                ts[i] = sc.nextInt();

            int thresh1 = (p == 1 ? 1 : (3 * p - 4));
            int thresh2 = (3 * p - 2);

            int count1 = 0, count2 = 0;

            for (int i = 0; i < n; ++i) {
                if (ts[i] >= thresh2) {
                    ++count2;
                    continue;
                }
                if (ts[i] >= thresh1) {
                    ++count1;
                }
            }

            if (count1 > s) {
                count1 = s;
            }

            System.out.format("Case #%d: %d%n", casenumber, count1 + count2);
        }
    }
}


import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Scanner;

public class ProblemB {

    public static void main(String[] args) throws IOException {
        Scanner s = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(new FileWriter("B.out"));
        int cas = s.nextInt();
        
        for( int i = 0; i < cas; i++){
            
            int N = s.nextInt();
            int S = s.nextInt();
            int p = s.nextInt();
            
            int noS = 0;
            int Pmaxs = 0;
            for( int n = 0; n < N; n++){
                int t = s.nextInt();
                int ter = t/3;
                
                    switch(t%3){
                        case 0:{
                            if(ter >= p){
                                Pmaxs++;
                            }else if(ter+1 >= p && ter+1 <= 10 && ter+1 <= t && ter-1 >= 0 ){
                                noS++;
                                Pmaxs++;
                            }
                            break;
                        }
                        case 1:{
                            if(ter >= p){
                                Pmaxs++;
                            }else if(ter+1 >= p && ter+1 <= 10){
                                Pmaxs++;
                            }
                            break;
                        }
                        case 2:{
                            if(ter >= p){
                                Pmaxs++;
                            }else if(ter+1 >= p && ter+1 <= 10){
                                Pmaxs++;
                            }else if(ter+2 >= p && ter+2 <= 10){
                                noS++;
                                Pmaxs++;
                            }
                            break;
                        }
                    }
                
            }
            if(noS > S){ Pmaxs -= (noS - S); }
            pw.println("Case #"+(i+1)+": "+Pmaxs);
        }
        pw.close();
        s.close();
    }
}
