import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;


public class Dancing {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		// read input file
		File file = new File("B-small-attempt4.in");
		//File file = new File("input.txt");
		BufferedReader br = new BufferedReader(new FileReader(file));
		String ln = "";
		int count = Integer.parseInt(br.readLine());

		// write output file
		File out = new File("outB.txt");
		BufferedWriter bw = new BufferedWriter(new FileWriter(out));
		
		int y = 0;
		for (int i=0; i < count; i++){
			ln = br.readLine();
			y = getY(ln);
			bw.write("Case #" + (i+1) + ": " + y);
			bw.newLine();
		}
		bw.close();
	}
	
	private static int getY(String str) {
		String[] data = str.split(" ");
		int n = Integer.parseInt(data[0]);
		int s = Integer.parseInt(data[1]);
		int p = Integer.parseInt(data[2]);
		int[] t = new int[n];
		for (int i=0; i < n; i++){
			t[i] = Integer.parseInt(data[i+3]);
		}
		int y = 0;
		int base = 0;
		for(int j=0; j < t.length; j++){
			base = t[j] / 3;
			if(base >= p) { y++; }
			else if(base == p-1){
				if(t[j] - (base+p) > base-1 && t[j] > 0){
					y++;
				} else if(s>0 && t[j] - (base+p) > base-2 && t[j] > 0){
					s -= 1;
					y++;
				}
			} else if(base == p-2){
				if(s > 0 && t[j] - (base+p) > base-1 && t[j] > 0){
					s -= 1;
					y++;
				}
			}
		}
		
		return y;
	}

}

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

public class Surprising {

    public static void main(String[]argsr)throws IOException
    {
        System.setOut(new PrintStream(new File("Surprising.out")));
        new DoSurprising();
    }

}

class DoSurprising
{
    int num, surp, target;
    Score[]scores;
    int max;

    public DoSurprising() throws IOException
    {
        Scanner sc = new Scanner(new File("Surprising.in"));
        int runs = Integer.parseInt(sc.nextLine().trim());
        int count = 0;
        while(count++<runs)
        {
            System.out.print("Case #"+count+": ");
            num = sc.nextInt();
            surp = sc.nextInt();
            target = sc.nextInt();
            scores = new Score[num];
            for(int i=0;i<num;i++)
                scores[i] = new Score(sc.nextInt());
            max = 0;
            find(0,0);
            System.out.println(max);
        }
    }

    void find(int ind, int sur)
    {
        if(sur == surp)
        {
            max = Math.max(max,targeted());
            //System.out.println(Arrays.toString(scores));
            return;
        }
        if(ind >= num)
            return;

        find(ind+1,sur);
        scores[ind].surprise();
        find(ind+1,sur+1);
        scores[ind].surprise();
    }

    int targeted()
    {
        int ret = 0;
        for(Score s : scores)
            if(s.get() >= target)
                ret++;
        return ret;
    }
}

class Score
{
    int[] surp, norm;
    int sum;
    boolean surprising;

    public Score(int sum)
    {
        this.sum = sum;
        surp = new int[3];
        norm = new int[3];
        int ave = sum / 3;
        int dif = sum - 3*ave;
        for(int i=0;i<3;i++)
        {
            norm[i] = ave + (i < dif ? 1 : 0);
            surp[i] = norm[i];
        }
        if(sum > 1)switch(dif)
        {
            case 0:surp[0]++;surp[1]--;break;
            case 1:surp[1]++;surp[2]--;break;
            case 2:surp[0]++;surp[1]--;break;
        }
        Arrays.sort(norm);
        Arrays.sort(surp);
    }
    
    int get()
    {
        return surprising ? getSurp() : getNorm();
    }

    int getNorm()
    {
        return norm[2];
    }

    int getSurp()
    {
        return surp[2];
    }

    void surprise()
    {
        surprising = !surprising;
    }

    public String toString()
    {
        return surprising ? Arrays.toString(surp) : Arrays.toString(norm);
    }
}
