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.util.Scanner;

/*
 * el resto es 0 --> puede ser caso especial y no
 * 		15 --> 5 5 5 Ã³ 4 5 6
 * el resto es 1 --> puede ser caso especial y no
 * 		16 --> 4 6 6 Ã³ 5 5 6
 * el resto es 2 --> puede ser caso especial y no
 * 		17 --> 5 7 7 Ã³ 5 6 6 
 */

public class B {
	public static void main(String[] args) {
		final int JUDGES = 3;
		final int MINSCORE = 0;
		Scanner in = new Scanner(System.in);
		int t = in.nextInt();
		for (int i = 1; i <= t; i++) {
			int n = in.nextInt();
			int s = in.nextInt();
			int p = in.nextInt();
			int success = 0;
			for (int j = 0; j < n; j++) {
				int totalScores = in.nextInt();
				int score = totalScores / JUDGES;
				int rest = totalScores % JUDGES;
				if (totalScores==MINSCORE) {
					if (p==MINSCORE) { 
						success++;
					}
				} else if (score >= p || (score+1>=p && rest>=1)) {
					success++;
				} else if (score + 1 >= p && rest < 1 && s > 0) {
					success++;
					s--;
				} else if (score + 2 >= p && rest == 2 && s > 0) {
					success++;
					s--;
				}
			}
			System.out.format("Case #%d: %d\n", i, success);
		}
	}
}