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.io.*;
import java.util.*;
public class Qual22B
{
	public static void main(String[] args) throws IOException
	{
		BufferedReader ips=new BufferedReader(new FileReader("B-large.in"));
		PrintWriter ops=new PrintWriter(new FileWriter("dwgop.in"));
		int T=Integer.parseInt(ips.readLine());
		for(int i=0; i<T;i++)
		{
			String line=ips.readLine();
			char[] ca=line.toCharArray();
			int j=0, G=0, S=0, p=0;
			for(j=0; ca[j]!=' ';j++)
				G=(G*10)+(ca[j]-'0');
			//System.out.println("Googlers: "+G);
			j++;
			for( ; ca[j]!=' ';j++)
				S=(S*10)+(ca[j]-'0');
			j++;
			//System.out.println("Surprises: "+S);
			for( ; ca[j]!=' ';j++)
				p=(p*10)+(ca[j]-'0');
			//System.out.println("Best score: "+p);
			j++;
			int[] ts= new int[G];
			for(int k=0; k<G; k++)
				ts[k]=0;
			for(int k=0; k<G;k++)
			{
				while( j<ca.length  && ca[j]!= ' ')
				{
					ts[k]=(ts[k]*10)+(ca[j]-'0');
					//System.out.print(ts[k]+" ");
					j++;
				}
				j++;
			}
			//System.out.println("");
			Arrays.sort(ts);
			int mod=0, sc=0, count=0;
			int[][] marks=new int[G][3];
			for(int k=G-1; k>=0; k--)
			{
				mod=ts[k]%3;
				for(int l=0; l<3; l++)
					marks[k][l]=ts[k]/3;
				if(mod==2)
				{
					if(sc<S && marks[k][0]!=9 && (((ts[k]/3)+2) == p )) 
					{
						marks[k][0]= marks[k][0]+2;
						sc++;
					}
					else
					{
						for(int l=0; l<2; l++)
							marks[k][l]=marks[k][l]+1;
					}		
				}
				else
				{
					if(mod==1)
					{
						marks[k][0]=marks[k][0]+1;
					}
					else
					{
						if(mod==0 && (((ts[k]/3)+1) ==p) && (ts[k]/3 != 0))
						{
							if(sc<S)
							{
								marks[k][0]=marks[k][0]+1;
								marks[k][1]=marks[k][1]-1;
								sc++;
							}
						}
					}
				}
			} 
			for(int k=0; k<G; k++)
			{
				for(int l=0; l<3; l++)
				{
					//System.out.print(marks[k][l]+" ");
					if(marks[k][l]>=p)
					{
						count++;
						break;
					}
				}
				//System.out.println("");
			}
			ops.println("Case #"+(i+1)+": "+count);
		}
		ips.close();
		ops.close();
	}
}