/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package codejam.common;

import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author Lance Chen
 */
public class CodeHelper {

    private static String FILE_ROOT = "D:/workspace/googlecodejam/meta";

    public static List<List<String>> loadInputsExcludes(String fileName) {
        List<List<String>> result = new ArrayList<List<String>>();
        List<String> lines = FileUtil.readLines(FILE_ROOT + fileName);
        int index = 0;
        for (String line : lines) {
            if (index == 0) {
                index++;
                continue;
            }
            if (index % 2 == 1) {
                index++;
                continue;
            }
            List<String> dataList = new ArrayList<String>();
            String[] dataArray = line.split("\\s+");
            for (String data : dataArray) {
                if (data.trim().length() > 0) {
                    dataList.add(data);
                }
            }
            result.add(dataList);
            index++;
        }
        return result;
    }

    public static List<List<String>> loadInputs(String fileName) {
        List<List<String>> result = new ArrayList<List<String>>();
        List<String> lines = FileUtil.readLines(FILE_ROOT + fileName);
        for (String line : lines) {
            List<String> dataList = new ArrayList<String>();
            String[] dataArray = line.split("\\s+");
            for (String data : dataArray) {
                if (data.trim().length() > 0) {
                    dataList.add(data);
                }
            }
            result.add(dataList);
        }
        return result;
    }

    public static List<String> loadInputLines(String fileName) {
        return FileUtil.readLines(FILE_ROOT + fileName);
    }

    public static void writeOutputs(String fileName, List<String> lines) {
        FileUtil.writeLines(FILE_ROOT + fileName, lines);
    }
}


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

public class Solution {
	public static void main(String args[]){
		try{
		FileInputStream fin=new FileInputStream("C:\\Program lang\\Google Code Jam\\input00.txt");
		DataInputStream datain=new DataInputStream(fin);
		BufferedReader br=new BufferedReader(new InputStreamReader(datain));
		int T=Integer.parseInt(br.readLine());
		for(int j=0;j<T;j++){
		StringTokenizer st=new StringTokenizer(br.readLine());
		int N=Integer.parseInt(st.nextToken());// googlers
		int S=Integer.parseInt(st.nextToken());// surprising triplets
		int p=Integer.parseInt(st.nextToken());// least max of triplet
		int out=0;
		for(int i=0;i<N;i++){
			int num=Integer.parseInt(st.nextToken());
			if(num%3==0){
				if(num/3>=p){
					out++;
				}
				else if((num+3)/3==p && S>0 && num>=3)	{
					S--;
					out++;
				}
				
			}
			else if(num%3==1){
				if((num+2)/3>=p)	out++;
			}
			else{
				if((num+1)/3>=p && num>=2)	out++;
				else if((num+4)/3>=p && S>0 && num>=2) {
					out++;
					S--;
				}
			}
		}
		System.out.println("Case #"+(j+1)+": "+out);
		
		}
		
		}catch(Exception e){
			System.out.println(e);
		}
	}
	
}