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 dancinggooglers;

import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;

/**
 *
 * @author Alfred
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
    try {
            FileInputStream fstream = new FileInputStream("B-small-attempt3.in");
            DataInputStream in = new DataInputStream(fstream);
            BufferedReader br = new BufferedReader(new InputStreamReader(in));
            FileWriter outFile = new FileWriter("out.txt");
            PrintWriter out = new PrintWriter(outFile);
            String line;
            HashMap<Integer,Integer[]> map = new HashMap<Integer,Integer[]>();
            map.put(0, new Integer[] {0, 0, 0});
            map.put(1, new Integer[] {1, 0, 0});
            map.put(2, new Integer[] {1, 1, 0});
            map.put(3, new Integer[] {1, 1, 1});
            map.put(4, new Integer[] {2, 1, 1});
            map.put(5, new Integer[] {2, 2, 1});
            map.put(6, new Integer[] {2, 2, 2});
            map.put(7, new Integer[] {3, 2, 2});
            map.put(8, new Integer[] {3, 3, 2});
            map.put(9, new Integer[] {3, 3, 3});
            map.put(10, new Integer[] {4, 3, 3});
            map.put(11, new Integer[] {4, 4, 3});
            map.put(12, new Integer[] {4, 4, 4});
            map.put(13, new Integer[] {5, 4, 4});
            map.put(14, new Integer[] {5, 5, 4});
            map.put(15, new Integer[] {5, 5, 5});
            map.put(16, new Integer[] {6, 5, 5});
            map.put(17, new Integer[] {6, 6, 5});
            map.put(18, new Integer[] {6, 6, 6});
            map.put(19, new Integer[] {7, 6, 6});
            map.put(20, new Integer[] {7, 7, 6});
            map.put(21, new Integer[] {7, 7, 7});
            map.put(22, new Integer[] {8, 7, 7});
            map.put(23, new Integer[] {8, 8, 7});
            map.put(24, new Integer[] {8, 8, 8});
            map.put(25, new Integer[] {9, 8, 8});
            map.put(26, new Integer[] {9, 9, 8});
            map.put(27, new Integer[] {9, 9, 9});
            map.put(28, new Integer[] {10, 9, 9});
            map.put(29, new Integer[] {10, 10, 9});
            map.put(30, new Integer[] {10, 10, 10});
            line = br.readLine();
            int cases = Integer.parseInt(line);
            for (int i=1; i<=cases;i++){
                line = br.readLine();
                String[] values = line.split(" ");
                int N = Integer.parseInt(values[0]);
                int S = Integer.parseInt(values[1]);
                int p = Integer.parseInt(values[2]);
                Integer[] scores = new Integer[N];
                for (int j = 0; j< N; j++){
                    scores[j] = Integer.parseInt(values[3+j]);
                }
                Arrays.sort(scores, Collections.reverseOrder());
                int total=0;
                for (int j = 0; j< N; j++){
                    Integer[] triplet = map.get(scores[j]).clone();
                    if(triplet[0]>=p){
                        total++;
                    }
                    else{
                        if (S > 0){
                            if(surprising(triplet,scores[j])){
                                if(triplet[0]>=p){
                                    S--;
                                    total++;
                                }
                            }
                        }
                    }
                }
                out.println("Case #"+i+": "+total);
                
            }
            in.close();
            out.close();
        } catch (Exception e) {//Catch exception if any
            System.err.println("Error: " + e.getMessage());
        }
    }

    private static boolean surprising(Integer[] triplet, int score) {
        if(score < 2 || score> 27)
            return false;
        else{
            if(triplet[0]==triplet[1]){
                triplet[0]++;
                triplet[1]--;
                Arrays.sort(triplet,Collections.reverseOrder());
                return true;
            }
            else{
                triplet[1]++;
                triplet[2]--;
                Arrays.sort(triplet,Collections.reverseOrder());
                return true;
            }
        }
    }

}