package googlers;

import java.util.Scanner;
import java.util.PriorityQueue;
import java.util.Comparator;
public class Googlers {
	
	public static void main(String[] args) {
		
		int n,s,p,count=0,t;		
		Scanner sin=new Scanner(System.in);
		
		t=Integer.parseInt(sin.nextLine());
		
		
		int result[]=new int[t];
		int j=0;
		
		if(t>=1 && t<=100)
		{
		for (int k = 0; k < t; k++) {
		count=0;	
		
			
        String ip = sin.nextLine();
        
        String[]tokens=ip.split(" ");
		
		
		n=Integer.parseInt(tokens[0]);
		s=Integer.parseInt(tokens[1]);
		p=Integer.parseInt(tokens[2]);
		
		if( (s>=0 && s<=n) && (p>=0 && p<=10) )
		{
		int[] total=new int[n];
		
		
		for (int i = 0; i < n; i++)
        {
            total[i] = Integer.parseInt(tokens[i+3]);
        }
		
		Comparator comparator=new PointComparator();
		PriorityQueue pq=new PriorityQueue<Point>(1, comparator);
		
		for (int i = 0; i < n; i++)
		{
			
			int x=total[i]/3;
			int r=total[i]%3;
			if(x>=p)
				count++;
			else if(x<(p-2))
				continue;
			else
			{
				//System.out.println("enter "+x+" "+(p-2));
				if(p-x==1)
				{
					Point temp=new Point();
					temp.q=x;
					temp.r=r;
					pq.add(temp);
				}
				else  // p-x=2
				{
					if(r==0)
						continue;
					else
					{
						Point temp=new Point();
						temp.q=x;
						temp.r=r;
						pq.add(temp);
					}				
					
				}
					
			}
			//System.out.println("hi "+pq.size());
			
		}
		
		
		
		while(pq.size()!=0)
		{
			Point temp=(Point)pq.remove();
			if(p-temp.q==1 && temp.q!=0)
			{
				if(temp.r>=1)
					count++;
				else
				{
					if(s!=0)
					{
						s--;
						count++;
					}
				}
			}
			else if(p-temp.q==2)
			{
				if(s!=0 && (temp.q+temp.r)>=p)
				{
					s--;
					count++;
				}
			}
			
				
		}
		
		//System.out.println(p);
		
		result[j++]=count;
		
		}
		}
		
		for (int i = 0; i < t; i++) 
		{
			System.out.println("Case #"+(i+1)+": "+result[i]);
		}
		}
		
	}
        
        
		
		/*Point x=new Point();
		x.q=8;
		Point y=new Point();
		y.q=6;
		Point z=new Point();
		z.q=7;
		
		pq.add(x);
		pq.add(y);
		pq.add(z);
		*/
		
		
		
		
	

}

class PointComparator implements Comparator<Point>
{
    @Override
    public int compare(Point x, Point y)
    {
        // Assume neither string is null. Real code should
        // probably be more robust
        if (x.q < y.q)
        {
            return 1;
        }
        if (x.q  > y.q)
        {
            return -1;
        }
        return 0;
    }
}



class Point
{
	int q,r;

	public int getQ() {
		return q;
	}

	public void setQ(int q) {
		this.q = q;
	}

	public int getR() {
		return r;
	}

	public void setR(int r) {
		this.r = r;
	}
	
	
}

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package googlers;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
/**
 *
 * @author Floran
 */
public class Googlers {

    int nbCase;
	static String inName;
	static String outName;
        public final char h=(char) 104;
	
	public static void solve() throws IOException{
		PrintWriter out=new PrintWriter(new BufferedWriter(new FileWriter(outName)));
		//Scanner in=new Scanner("A-small-practice.txt");
		BufferedReader in=new BufferedReader(new FileReader(inName));
		String ligne=in.readLine();
                // nb de cas
		System.out.println(ligne);
		int nbCase=Integer.parseInt(ligne);
                //compte
                int count=0;
                for(int i=1;i<=nbCase;i++){
                    int ns=0;//nb suprise
                    count=0;
                    String[] parametre=in.readLine().split(" ");
                    System.out.println("lenght"+parametre.length);
                    int nb=Integer.parseInt(parametre[0]);//nb de participant
                    System.out.println("nb"+nb);
                    int suprise=Integer.parseInt(parametre[1]);//nb de triplet surprise
                    System.out.println("sup"+suprise);
                    int min=Integer.parseInt(parametre[2]);//un quote du triplet doit Ãªtre >=min
                    for(int m=3;m<nb+3;m++){
                        //int[][] tab=decomposition(Integer.parseInt(parametre[i]));
                        int[] tab=decomp(Integer.parseInt(parametre[m]));
                        if(tab.length==1){
                            //if(tab[0][2]>=min)
                            if(tab[0]>=min)
                                count++;
                        }
                        else{
                            //if(tab[0][2]>=min)
                            if(tab[0]>=min)
                                count++;
                            //else if(tab[0][2]>=min &&ns<=suprise){
                            else if(tab[1]>=min && ns<suprise){
                                ns++;
                                count++;
                            }
                        }
                    }
                    out.println("Case #"+i+": "+count);	
		}
		out.flush();
		out.close();
		in.close();
	}
   /* public static int[][] decomposition(int quote){
        int mod=quote%3;
        int div=quote/3;
        int[][] tab;
        if(mod==1){
            tab=new int[1][3];
            tab[0][0]=div;
            tab[0][1]=div;
            tab[0][2]=div+1;
            return tab;
        }
        if(mod==2){
            tab=new int[2][3];
            tab[0][0]=div;
            tab[0][1]=div+1;
            tab[0][2]=div+1;
            
            tab[1][0]=div;
            tab[1][1]=div;
            tab[1][2]=div+2;
            
            return tab;
        }
        else{
            tab=new int[2][3];
            tab[0][0]=div;
            tab[0][1]=div;
            tab[0][2]=div;
            
            tab[1][0]=div;
            tab[1][1]=div-1;
            tab[1][2]=div+1;
            
            return tab;
        }
    }*/
    public static int[] decomp(int quote){
        int mod=quote%3;
        int div=quote/3;
        int[] tab;
        if(mod==1){
            tab=new int[1];
            tab[0]=div+mod;
            return tab;
        }
        if(mod==2){
            tab=new int[2];
            tab[0]=div+(mod/2);
            tab[1]=div+mod;
            
            return tab;
        }
        else{
            tab=new int[2];
            tab[0]=div;
            if(quote==0)
                tab[1]=div;
            else
                tab[1]=div+1;
            
            return tab;
        }
    }
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        //inName="A-small-practice.txt";
                //inName="test.txt";
		//outName="solution7.txt";
		inName="B-small-attempt4.in";
		outName="solution_small4.txt";
		//inName="A-large-practice.in";
		//outName="Large_solution.txt";
		try{
			solve();
		}
		catch(IOException e){
			System.out.println(e.getMessage());
		}
		System.out.println("fini");
    }
}
