/**
 * Created by IntelliJ IDEA.
 * User: Administrator
 * Date: 3/3/12
 * Time: 11:00 AM
 * To change this template use File | Settings | File Templates.
 */

import SRMLib.MathLibrary;
import SRMLib.TestSRMLib;
import com.sun.org.apache.bcel.internal.generic.F2D;

import java.io.*;
import java.util.*;
import java.util.zip.Inflater;

public class SRM {
    public static void main(String[] args) throws IOException {
        //TestSRMLib.run();
        codeJam1.main();

        return;
    }
}
class codeJam1 {
    public static void main() throws IOException {
        String inputPath = "E:\\input.txt";
        String outputPath = "E:\\output.txt";
        BufferedReader input = new BufferedReader(new FileReader(inputPath));
        BufferedWriter output = new BufferedWriter(new FileWriter(outputPath));

        String line;
        line = input.readLine();
        int T = Integer.parseInt(line);
        for (int i = 1; i <= T; ++i) {
            line = input.readLine();
            String[] words = line.split(" ");
            int N = Integer.parseInt(words[0]);
            int S = Integer.parseInt(words[1]);
            int p = Integer.parseInt(words[2]);
            int n = 0;
            int res = 0;

            for (int j = 3; j < words.length; ++j) {
                if (p == 0) {
                    res++;
                    continue;
                }

                int t = Integer.parseInt(words[j]);
                if (p == 1) {
                    if (t > 0)
                        res++;
                    continue;
                }
                if (t >= 3 * p - 2)
                    res++;
                else if (t >= 3 * p - 4)
                    n++;
            }

            res += Math.min(n, S);
            output.write("Case #" + i + ": " + res);
            output.newLine();
        }

        input.close();
        output.close();
    }
}

package home.lviv;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

public class Main {
	public static void proA(BufferedReader reader, BufferedWriter writer)
			throws NumberFormatException, IOException {
		Map<Character, Character> map = new HashMap<Character, Character>(32);
		String text = "zejp mysljylc kd kxveddknmc re jsicpdrysi"
				+ "rbcpc ypc rtcsra dkh wyfrepkym veddknkmkrkcd"
				+ "de kr kd eoya kw aej tysr re ujdr lkgc jvq", mapping = "qour language is impossible to understand"
				+ "there are twenty six factorial possibilities"
				+ "so it is okay if you want to just give upz";
		for (int i = 0; i < text.length(); i++) {
			map.put(Character.valueOf(text.charAt(i)),
					Character.valueOf(mapping.charAt(i)));
		}
		int T;
		T = Integer.parseInt(reader.readLine());
		for (int t = 0; t < T; t++) {
			String in, out = "";
			in = reader.readLine();
			for (int i = 0; i < in.length(); i++) {
				if (map.get(in.charAt(i)) == null) {
					System.out.println("null is " + in.charAt(i));
				}
				out += map.get(in.charAt(i));
			}
			writer.write("Case #" + (t + 1) + ": " + out + "\n");
		}
	}

	public static void proB(BufferedReader reader, BufferedWriter writer)
			throws NumberFormatException, IOException {
		int T = Integer.parseInt(reader.readLine());
		for (int t = 0; t < T; t++) {
			String[] temp = reader.readLine().split(" ");
			int N = Integer.parseInt(temp[0]), S = Integer.parseInt(temp[1]), p = Integer
					.parseInt(temp[2]), G = 0;
			int[] n = new int[N];
			ArrayList<Integer> integers = new ArrayList<Integer>(N);
			for (int i = 0; i < N; i++) {
				n[i] = Integer.parseInt(temp[3 + i]);
				if (((n[i] / 3) >= p)) {
					G++;
					continue;
				} else {
					if (((n[i] / 3) >= p - 1) && (n[i] > 0) && (n[i] % 3 > 0)) {
						G++;
						continue;
					}
					if (((n[i] / 3) >= p - 1) && (n[i] > 0) && (S > 0)) {
						G++;
						S--;
						continue;
					}
					if (((n[i] / 3) >= p - 2) && (n[i] > 0) && (n[i] % 3 > 1)
							&& (S > 0)) {
						G++;
						S--;
						continue;
					}
				}
			}
			writer.write("Case #" + (t + 1) + ": " + (G) + "\n");
		}
	}

	public static void main(String[] args) throws IOException {
		BufferedReader input = new BufferedReader(new InputStreamReader(
				new FileInputStream("/home/taras/codejam/data.in")));
		BufferedWriter output = new BufferedWriter(new OutputStreamWriter(
				new FileOutputStream("/home/taras/codejam/data.out")));
		proB(input, output);
		input.close();
		output.close();
	}
}
