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);
        }
    }
}

package second;

public class Triples {
	private int [] values;
	private int surprise=-1;
	private boolean Boolsurprise;
	int maxValue=-1;

	
	public Triples (int a,int b ,int c){
		values=new int [3];
		values[0]=a;
		values[1]=b;
		values[2]=c;
	}
	public int sum(){
		return values[0]+values[1]+values[2];
	}
	
	public boolean isSurprise(){
		if(surprise==-1)
			calculateSurprise();
		return Boolsurprise;
	}
	private void calculateSurprise() {
		surprise=1;
		if(Math.abs(values[0]-values[1])>=2)
			Boolsurprise=true;
		if(Math.abs(values[0]-values[2])>=2)
			Boolsurprise=true;
		if(Math.abs(values[1]-values[2])>=2)
			Boolsurprise=true;
		
	}
	public int getMaxValue() {
		if(maxValue>0)
			return maxValue;
		int max=values[0];
		for(int i=1;i<values.length;i++)
			if(values[i]>max)
				max=values[i];
		maxValue=max;
		return maxValue;
	}
	@Override
	public String toString() {
		String s="";
		for(int i=0;i<values.length;i++)
			s+=values[i]+" ";
		if(isSurprise())
			s+="(*)";
		return s;
			
	}
}
