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;


public class Problem2 {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		int lineNo = scan.nextInt();
		
		for(int i = 0 ; i < lineNo ; i++) {
			int googlerNo = scan.nextInt();
			int surpriseNo = scan.nextInt();
			int point = scan.nextInt();
			
//			int googlerPoint[] = new int[googlerNo];
			Googler[] googlers = new Googler[googlerNo];
			
			int maxGoogler = 0;
			for(int j = 0 ; j < googlerNo ; j++) {
				googlers[j] = new Googler();
				
				googlers[j].setPoint(scan.nextInt());
				
				if(googlers[j].maxPoint >= point)
					maxGoogler++;
				
				else if(googlers[j].canSurprise 
					&& googlers[j].maxPoint+1 == point 
					&& surpriseNo > 0) {
					
					maxGoogler++;
					surpriseNo--;					
				}
			}
			
			System.out.println("Case #" + (i+1) + ": " + maxGoogler);
			
			
		}
	}
}

class Googler {
	int point;
	
	int minPoint;
	int maxPoint;
	
	boolean canSurprise;
	
	void setPoint(int point) {
		this.point = point;
		
		if(point == 0 || point % 3 == 1) canSurprise = false;
		else canSurprise = true;
		
		minPoint = point / 3;
		maxPoint = point % 3 == 0 ? minPoint : minPoint + 1;
	}
}
 