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 com.vlad;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Scanner;

public class B {
    public static void main(String[] args) throws IOException {
        Scanner scanner = new Scanner(new File(args[0]));
        FileWriter writer = new FileWriter("b-out.txt");
        int T = scanner.nextInt();
        for(int i=0;i<T;i++) {
            int N = scanner.nextInt();
            int S = scanner.nextInt();
            int P = scanner.nextInt();
            int[] RES = new int[N];
            
            for(int j=0;j<N;j++) {
                RES[j] = scanner.nextInt();
            }

            if(i>0) {
                writer.append("\n");
            }
            writer.append("Case #"+(i+1)+": " + solve(N,S,P,RES));
        }
        writer.flush();
    }

    private static int solve(int n, int s, int p, int[] res) {
        int num = 0;
        int surLeft = s;
        for(int i=0;i<n;i++) {
            if(p+Math.max(0,p-1)*2<=res[i]) {
                num++;
            } else {
                if(surLeft>0) {
                    if(p+Math.max(0,p-2)*2<=res[i]) {
                        surLeft--;
                        num++;
                    }
                }
            }
        }
        return num;
    }
}
