package codejam;

import fixjava.Pair;

public class Utils {

	public static long minLong(long firstVal, long... otherVals) {
		long minVal = firstVal;
		for (int i = 0; i < otherVals.length; i++)
			minVal = Math.min(firstVal, otherVals[i]);
		return minVal;
	}

	public static int minInt(int firstVal, int... otherVals) {
		int minVal = firstVal;
		for (int i = 0; i < otherVals.length; i++)
			minVal = Math.min(firstVal, otherVals[i]);
		return minVal;
	}

	public static float minFloat(float firstVal, float... otherVals) {
		float minVal = firstVal;
		for (int i = 0; i < otherVals.length; i++)
			minVal = Math.min(firstVal, otherVals[i]);
		return minVal;
	}

	/**
	 * ArgMin returned as a Pair<Integer, Integer>(index, value). Array must
	 * have at least one value.
	 */
	public static Pair<Integer, Integer> argMin(int[] arr) {
		int min = arr[0];
		int argMin = 0;
		for (int i = 1; i < arr.length; i++) {
			if (arr[i] < min) {
				min = arr[i];
				argMin = i;
			}
		}
		return new Pair<Integer, Integer>(argMin, min);
	}

	/**
	 * ArgMax returned as a Pair<Integer, Integer>(index, value). Array must
	 * have at least one value.
	 */
	public static Pair<Integer, Integer> argMax(int[] arr) {
		int max = arr[0];
		int argMax = 0;
		for (int i = 1; i < arr.length; i++) {
			if (arr[i] > max) {
				max = arr[i];
				argMax = i;
			}
		}
		return new Pair<Integer, Integer>(argMax, max);
	}

}

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

package codejam12;

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

/**
 *
 * @author Mohamed Ibrahim (MIM)
 */
public class Problem_B {
    public static void main(String[] args) throws IOException {
        
        BufferedReader r = new BufferedReader(new FileReader("B-large.in"));
        PrintWriter w = new PrintWriter(new BufferedWriter(new FileWriter("B-large.out")));
        
        int nCases = Integer.parseInt(r.readLine());
        
        for (Integer k = 1; k <= nCases; k++) {
            int ret=0;
            w.print("Case #" + k + ": ");
            String line=r.readLine();
            StringTokenizer st = new StringTokenizer(line);
            int n= Integer.parseInt(st.nextToken());
            int more= Integer.parseInt(st.nextToken());
            int p= Integer.parseInt(st.nextToken());
            
            for (int i = 0; i <n; i++) {
                int cur= Integer.parseInt(st.nextToken());
                int div=cur/3;
                int rem=cur-div*3;
                if(p==0){
                    ret=n;
                    break;
                }
                if(cur==0)continue;
                if(div>=p)ret++;
                else{
                    if(p-div==1 && rem>0)ret++;
                    else if(p-div==1 && more>0){
                        ret++;
                        more--;
                    }
                    else if(p-div==2 && rem==2 && more>0){
                        ret++;
                        more--;
                    }
         /*           else if(p-div==2 && more>0 && rem>0){
                        ret++;
                        more--;
                    }*/
                }
            }
            
            w.println(ret);
        }
        w.close();
        
        
    }
}
