package com.gcj.parser;

public class MaxPoints {

	public static int normal(int value){
		int toReturn = 0;
		switch (value) {
		case 0 : toReturn = 0 ; break;
		case 1 : toReturn = 1 ; break;
		case 2 : toReturn = 1 ; break;
		case 3 : toReturn = 1 ; break;
		case 4 : toReturn = 2 ; break;
		case 5 : toReturn = 2 ; break;
		case 6 : toReturn = 2 ; break;
		case 7 : toReturn = 3 ; break;
		case 8 : toReturn = 3 ; break;
		case 9 : toReturn = 3 ; break;
		case 10 : toReturn = 4 ; break;
		case 11 : toReturn = 4 ; break;
		case 12 : toReturn = 4 ; break;
		case 13 : toReturn = 5 ; break;
		case 14 : toReturn = 5 ; break;
		case 15 : toReturn = 5 ; break;
		case 16 : toReturn = 6 ; break;
		case 17 : toReturn = 6 ; break;
		case 18 : toReturn = 6 ; break;
		case 19 : toReturn = 7 ; break;
		case 20 : toReturn = 7 ; break;
		case 21 : toReturn = 7 ; break;
		case 22 : toReturn = 8 ; break;
		case 23 : toReturn = 8 ; break;
		case 24 : toReturn = 8 ; break;
		case 25 : toReturn = 9 ; break;
		case 26 : toReturn = 9 ; break;
		case 27 : toReturn = 9 ; break;
		case 28 : toReturn = 10 ; break;
		case 29 : toReturn = 10 ; break;
		case 30 : toReturn = 10 ; break;

		}

		return toReturn;
	}

	public static int surprising(int value){
		int toReturn = 0;
		switch (value) {
		case 0 : toReturn = 0 ; break;
		case 1 : toReturn = 1 ; break;
		case 2 : toReturn = 2 ; break;
		case 3 : toReturn = 2 ; break;
		case 4 : toReturn = 2 ; break;
		case 5 : toReturn = 3 ; break;
		case 6 : toReturn = 3 ; break;
		case 7 : toReturn = 3 ; break;
		case 8 : toReturn = 4 ; break;
		case 9 : toReturn = 4 ; break;
		case 10 : toReturn = 4 ; break;
		case 11 : toReturn = 5 ; break;
		case 12 : toReturn = 5 ; break;
		case 13 : toReturn = 5 ; break;
		case 14 : toReturn = 6 ; break;
		case 15 : toReturn = 6 ; break;
		case 16 : toReturn = 6 ; break;
		case 17 : toReturn = 7 ; break;
		case 18 : toReturn = 7 ; break;
		case 19 : toReturn = 7 ; break;
		case 20 : toReturn = 8 ; break;
		case 21 : toReturn = 8 ; break;
		case 22 : toReturn = 8 ; break;
		case 23 : toReturn = 9 ; break;
		case 24 : toReturn = 9 ; break;
		case 25 : toReturn = 9 ; break;
		case 26 : toReturn = 10 ; break;
		case 27 : toReturn = 10 ; break;
		case 28 : toReturn = 10 ; break;
		case 29 : toReturn = 10 ; break;
		case 30 : toReturn = 10 ; break;

		}
		return toReturn;
	}

}

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

public class Problem2
{
    static ArrayList<Integer> scores;
    public static void main(String args[])
    {
        try
        {
            FileInputStream fstream = new FileInputStream("B-large.in");
            DataInputStream in = new DataInputStream(fstream);
            BufferedReader br = new BufferedReader(new InputStreamReader(in));
            
            String line;
            int total;
            int i = 0, cases;
            Scanner sc;
            int number, surprising, minpoints;
            while ((line = br.readLine()) != null)
            {
                if(i == 0)
                {
                    total = Integer.parseInt(line);
                    i = 1;
                    continue;
                }
                sc = new Scanner(line);
                scores = new ArrayList<Integer>();
                number = sc.nextInt();
                surprising = sc.nextInt();
                minpoints = sc.nextInt();
                cases = 0;
                for(int j = 0; j < number; j++)
                {
                    scores.add(sc.nextInt());
                }
                for(int score : scores)
                {
                    int base = (int)(score/3);
                    
                    switch(score%3)
                    {
                        case 0:
                        {
                            if(base>=minpoints)
                            {
                                cases++;
                            }
                            else if(surprising > 0 && base > 0 && base + 1 >= minpoints)
                            {
                                cases++;
                                surprising--;
                            }
                            break;
                        }
                        case 1:
                        {
                            if(base>=minpoints | base + 1 >= minpoints)
                            {
                                cases++;
                            }
                            else if(surprising > 0 && base + 1 >= minpoints)
                            {
                                cases++;
                                surprising--;
                            }
                            break;
                        }
                        case 2:
                        {
                            if(base + 1>= minpoints | base>=minpoints)
                            {
                                cases++;
                            }
                            else if(surprising > 0 && base + 2 >= minpoints)
                            {
                                cases++;
                                surprising--;
                            }
                            break;
                        }
                    }
                }
                System.out.println("Case #"+i+": "+cases);
                write("Case #"+i+": "+cases);
                i++;
            }
            in.close();
        }catch (Exception e){
            System.err.println("Error: " + e.getMessage());
        }       
    }
    
 
    public static void write(String text)
    {
        try
        {
            BufferedWriter bw = new BufferedWriter(new FileWriter(new File("Problem2Large.out"), true));
            bw.write(text);
            bw.newLine();
            bw.close();
        }catch (Exception e) {
            System.err.println("Error: " + e.getMessage());
        }
    }
}