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.util.ArrayList;

public class DancingWG{
	public static void main(String[] args){
		ArrayList<String> inputs = IOGoogleCodeJam.fileInput(args[0]);
		ArrayList<String> outputs= new ArrayList<String>();
		int lines=Integer.parseInt(inputs.get(0));
		for(int i=1;i<=lines;i++){
			outputs.add(processData(inputs.get(i)));
		}
		IOGoogleCodeJam.resultsOutput(outputs,1);
	}

	public static String processData(String s){
		String aux[] = s.split(" ");
		int N = Integer.parseInt(aux[0]);
		int S = Integer.parseInt(aux[1]);
		int p = Integer.parseInt(aux[2]);
		int c = 0; //count googlers
		for(int i=3;i<aux.length;i++){
			int x = Integer.parseInt(aux[i]);
			int y = 0;
			switch(x%3){
				case 0: y=x/3;
					if(y>=p){
						c++;
					}else if(y>0){//if 0 reach here, it doesn't count
						y=(x+3)/3;
						if(y<=10 && y>=p && S>0){
							c++;
							S--;
						}
					}
					break;
				case 1: y=(x+2)/3;
					if(y>=p){
						c++;//I dont care if there's a surprise here
					}
					break;
				case 2: y=(x+1)/3;
					if(y>=p){
                                        	c++;
                                        }else{
                                                y=(x+4)/3;
                                                if(y<=10 && y>=p && S>0){
                                                	c++;
                                                        S--;
                                                }
                                        }
					break;
			}
		}
		return String.valueOf(c);
	}
}
