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.Scanner;
import java.io.*;
import java.util.ArrayList;
public class Main2
{
	public static void main(String[] args) throws IOException
	{
		String line = " ";
		String line2 = " ";
		String line3 = " ";
		FileReader reader = new FileReader("B-large.in");
		Scanner in = new Scanner(reader);
		ArrayList<String> list = new ArrayList<String>();
		ArrayList<String> list2 = new ArrayList<String>();
		int number = 0;
		int numb = 0;
		int index = 0;
		
		int c;
		int N;
		int nprob;
		int hnum;
		int calc;
		boolean suc;
		int p;
		int[] num = new int[103];
		
		int count = in.nextInt();
		in.nextLine();
		
		for(int i = 0; i < count; i++)
		{
			line = in.nextLine();
			list.add(line);
		}
			
		while(count > 0)
		{
			p = 0;
			line2 = list.get(numb);
			number = 0;
			
			while(line2.length() > 0)
			{
				index = line2.indexOf(' ');
				if(index > 0)
				{
					line = line2.substring(0,index);
					num[number] = Integer.parseInt(line);
					line2 = line2.substring(index);
					line2 = line2.trim();
				}
				else if(index == -1)
				{
					num[number] = Integer.parseInt(line2);
					line2 = "";
				}
				number++;
			}
			
			
			
			N = num[0];
			nprob = num[1];
			hnum = num[2];
			suc = false;
			
			for(int j = 0; j < N; j++)
			{
				c = 3;
				calc = num[j+3];
				while(c > 0)
				{
					calc -= hnum;
					c--;
				}
			
				if(calc >= 0)
					suc = true;
				else if(calc == -1)
					suc = true;
				else if(calc == -2)
					suc = true;
				else if(nprob > 0 && calc == -3 && num[j+3] > 0)
				{
					suc = true;
					nprob--;
				}
				else if(nprob > 0 && calc == -4 && num[j+3] > 0)
				{
					suc = true;
					nprob--;
				}
				else
					suc = false;
					
				if(suc)
					p++;	
			}
			
										
			line3 = "Case #" + (numb+1) + ": " + p;
			list2.add(line3);
			count--;
			numb++;
			
		}
		
		for(String a : list2)
			System.out.println(a);
		
						
	}
}