package dancinggooglers;

import java.io.File;
import java.util.Scanner;

public class DanceScoreCalculator {


    public static void main(String[] args) {
        if(args.length <= 0 || args[0] == null) {
            System.out.println("You must enter a file to read");
            System.out.println("Usage: blah <filename>");
            System.exit(0);
        }

        File argFile = new File(args[0]);
        try {
            Scanner googleSpeakScanner = new Scanner(argFile);
            String firstLine = googleSpeakScanner.nextLine();
            Integer linesToScan = new Integer(firstLine);
            for(int i = 1; i <= linesToScan; i++) {
                String googleDancerLine = googleSpeakScanner.nextLine();
                DanceScoreCase danceCase = new DanceScoreCase(googleDancerLine);
                System.out.println(String.format("Case #%d: %d", i, danceCase.maxDancersThatCouldPass()));
            }
        }
        catch (Exception e) {
            e.printStackTrace();
        }
    }
}

import java.io.*;

public class template {
	public static void main(String[] args) throws IOException {
		StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
		PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
		//PrintWriter out = new PrintWriter("output.txt");
		
		in.nextToken(); int count = (int)in.nval;
		
		for(int c = 1 ; c <= count ; c++) {
			in.nextToken(); int googlers = (int) in.nval;
			in.nextToken(); int surprisings = (int) in.nval;
			in.nextToken(); int passScore = (int) in.nval;
			
			int pass = 0;
			int passWithSurprising = 0;			

			// loop through scores
			for(int i = 0 ; i < googlers ; i++) {
				in.nextToken(); int score = (int) in.nval;
				
				int division = score / 3;
				int modulo = score % 3;
				
				if (modulo > 0) division++;
				
				if (division >= passScore) {
					pass++;
				} else if (division+1 == passScore && modulo!=1 && score!=0) {
					passWithSurprising++;
				}
			}
			
			out.println("Case #" + c + ": " + (pass + Math.min(passWithSurprising, surprisings)));
		}
		
		out.flush();
		out.close();
	}
}
