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 qualification;

import java.util.Scanner;

public class Dancing {
	
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		int num = scan.nextInt();
		for(int i=0; i<num; i++)
		{
			int numOfGooglers = scan.nextInt();
			int numOfSurprizes = scan.nextInt();
			int score = scan.nextInt();
			int[] totalScores = new int[numOfGooglers];
			for(int j=0; j<numOfGooglers; j++)
				totalScores[j] = scan.nextInt();
			
			System.out.println("Case #" + (i+1) + ": " + solve(numOfSurprizes, totalScores, score));
			
		}
	}

	private static int solve(int numOfSurprizes, int[] totalScores, int score) {
		int count = 0;
		int surprisesLeft = numOfSurprizes;
		for(int i=0; i<totalScores.length; i++) {
			if(totalScores[i]/3 + (totalScores[i]%3 != 0 ? 1 : 0) >= score)
				count++;
			else if(surprisesLeft > 0) {
				if(totalScores[i] > 0 && (totalScores[i]/3 + (totalScores[i]%3 == 2 ? 2 : 0) >= score || totalScores[i]/3 + 1 >= score)) {
					count++;
					surprisesLeft--;
				}
			}
		}
		return count;
	}

}
