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

public class DancingWithTheGooglers
{
    public DancingWithTheGooglers()
    {
        Scanner inFile = null;
        try
        {
            inFile = new Scanner(new File("inputB.txt"));
        }
        catch(Exception e)
        {
            System.out.println("Problem opening input file. Exiting...");
			System.exit(0);
        }
        int t = inFile.nextInt();
        
        int [] results = new int [t];
        DancingWithTheGooglersMax [] rnc = new DancingWithTheGooglersMax[t];
        
        int i, j;
        int [] scores;
        int s, p;
        for(i = 0; i < t; i++)
        {
            scores = new int [inFile.nextInt()];
            s = inFile.nextInt();
            p = inFile.nextInt();
            for(j = 0; j < scores.length; j++)
                scores[j] = inFile.nextInt();
            
            rnc[i] = new DancingWithTheGooglersMax(i, scores, s, p, results);
            rnc[i].start();
        }
        inFile.close();
        
        boolean done = false;
        
        while(!done)
        {
            done = true;
            for(i = 0; i < t; i++)
                if(rnc[i].isAlive())
                {
                    done = false;
                    break;
                }
        }
        
        PrintWriter outFile = null;
        try
        {
            outFile = new PrintWriter(new File("outputB.txt"));
        }
        catch(Exception e)
        {
            System.out.println("Problem opening output file. Exiting...");
			System.exit(0);
        }
        
        for(i = 0; i < results.length; i++)
            outFile.printf("Case #%d: %d\n", i+1, results[i]);
        outFile.close();
    }
    
    public static void main(String [] args)
    {
        new DancingWithTheGooglers();
    }
    
    private class DancingWithTheGooglersMax extends Thread
    {
        int id;
        int s, p;
        int [] results, scores;
        
        public DancingWithTheGooglersMax(int i, int [] aScores, int aS, int aP,int [] res)
        {
            id = i;
            s = aS;
            p = aP;
            results = res;
            scores = aScores;
        }
        
        public void run()
        {
            int a = 0, b = 0;
            
            if(p == 0)
                results[id] = scores.length;
            else if(p == 1)
            {
                int y;
                y = 3*p - 3;
                
                for(int i = 0; i < scores.length; i++)
                    if(scores[i] > y)
                        a++;
                    else if(scores[i] > 0)
                        b++;
                
                b = Math.min(b, s);
                results[id] = a+b;
            }
            else
            {
                int y, z;
                y = 3*p - 3;
                z = 3*p - 5;
                
                for(int i = 0; i < scores.length; i++)
                    if(scores[i] > y)
                        a++;
                    else if(scores[i] > z)
                        b++;
                
                b = Math.min(b, s);
                results[id] = a+b;
            }
        }
    }
}
import java.util.Arrays;
import java.util.Scanner;


public class Dancing {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner reader = new Scanner(System.in);
		int T = reader.nextInt();
		for(int tc = 1 ; tc <= T ; tc++ ) {
			int N = reader.nextInt();
			int S = reader.nextInt();
			int p = reader.nextInt();
			int [] arr = new int[N];
			for(int i = 0 ; i < N ; i ++) {
				arr[i] = reader.nextInt();
			}
			int res = doit(arr, S, p);
			System.out.printf("Case #%d: %d\n", tc, res);
		}
	}

	private static int doit(int[] arr, int s, int p) {
		int n = arr.length;
		Triplet[] ts = new Triplet[n];
		for(int i = 0 ; i < n ; i ++) {
			ts[i] = new Triplet(arr[i]);
		}
		Arrays.sort(ts);
		int count = 0;
		for(int i = 0 ; i < arr.length; i ++) {
			if ( ts[i].max >= p) {
				count ++;
//				System.out.println(ts[i].total + " used");
				continue;
			}
			if( s > 0 && ts[i].surprisingMax >= p) {
				s--;
				count ++;
//				System.out.println(ts[i].total + " used");
				continue;
			}
//			System.out.println(ts[i].total + "  " + s + p);
		}
		return count;
	}
}

class Triplet implements Comparable<Triplet> {
	int total;
	int max;
	int surprisingMax;
	public Triplet(int total) {
		this.total = total;
		initialize();
	}
	private void initialize() {
		int avg = total / 3;
		int remaining = total % 3;
		int a[] = new int[3];
		a[0] = avg;
		a[1] = avg;
		a[2] = avg;
		if(remaining > 0) {
			a[0]++;
		}
		if(remaining > 1) {
			a[1]++;
		}
		this.max = a[0];
		switch(remaining) {
		case 0:
		case 2:
			this.surprisingMax = a[0] + (a[1] > 0 ? 1 : 0);
			break;
		case 1:
			this.surprisingMax = -1;
			break;
		}
//		System.out.println("total: " + total + " max: " + max + " remaining: " + remaining + " surp max: " + surprisingMax);
	}
	@Override
	public int compareTo(Triplet o) {
		if(o.total != total) {
			return o.total - total;
		}
		if(o.max != max) {
			return o.max - max;
		}
		return o.surprisingMax - surprisingMax;
	}
}
