package com.silverduner.codejam;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.util.HashMap;

public class Dancing {
	public static void main(String[] args) throws Exception {
		File input = new File("B-small-attempt0.in");
		BufferedReader in = new BufferedReader(new FileReader(input));

		File output = new File("1.out");
		BufferedWriter out = new BufferedWriter(new FileWriter(output));

		// parse input
		int N = Integer.parseInt(in.readLine());
		for(int i=0;i<N;i++) {
			String str = in.readLine();
			out.write("Case #"+(i+1)+": ");
			System.out.println("-------");
			String[] words = str.split(" ");
			int n = Integer.parseInt(words[0]);
			int suprise = Integer.parseInt(words[1]);
			int threshold = Integer.parseInt(words[2]);
			int[] scores = new int[n];
			for(int j=0;j<n;j++) {
				scores[j] = Integer.parseInt(words[3+j]);
			}
			int count = 0;
			for(int score : scores) {
				int a,b,c;
				boolean find = false;
				boolean sfind = false;
				for(a = 10; a>=0 && !find; a--) {
					if(3*a-4>score)
						continue;
					for(b = a; b>=0 && b >=a-2 && !find; b--) {
						for(c = b; c>=0 && c >=b-2 && c >=a-2 && !find; c--) {
							System.out.println(a+","+b+","+c);
							if(a+b+c==score) {
								if(a >= threshold) {
									if(a-c <= 1){
										count++;
										find = true;
										System.out.println("find!");
									}
									else if(a-c == 2){
										sfind = true;
										System.out.println("suprise!");
									}
								}
							}
							
						}
					}
				}
				if(!find && sfind && suprise > 0)
				{
					count++;
					suprise --;
				}
			}
			int maxCount = count;
			out.write(maxCount+"\n");
		}
		out.flush();
		out.close();
		in.close();
	}
}

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

public class Qual2012 {
	
	public static void lame() {
		try {
			FileReader fr = new FileReader("input.txt");
			BufferedReader reader = new BufferedReader(fr);
			PrintWriter writer = new PrintWriter("output.txt");
			
			HashMap<String,String> dictionary = new HashMap<String,String>();
			dictionary.put("a", "y");
			dictionary.put("b", "h");
			dictionary.put("c", "e");
			dictionary.put("d", "s");
			dictionary.put("e", "o");
			dictionary.put("f", "c");
			dictionary.put("g", "v");
			dictionary.put("h", "x");
			dictionary.put("i", "d");
			dictionary.put("j", "u");
			dictionary.put("k", "i");
			dictionary.put("l", "g");
			dictionary.put("m", "l");
			dictionary.put("n", "b");
			dictionary.put("o", "k");
			dictionary.put("p", "r");
			dictionary.put("q", "z");
			dictionary.put("r", "t");
			dictionary.put("s", "n");
			dictionary.put("t", "w");
			dictionary.put("u", "j");
			dictionary.put("v", "p");
			dictionary.put("w", "f");
			dictionary.put("x", "m");
			dictionary.put("y", "a");
			dictionary.put("z", "q");
			dictionary.put (" ", " ");
			int numCases = Integer.parseInt(reader.readLine());
			
			for (int i = 1; i <= numCases; i++) {
				String sentence = reader.readLine();
				String newSentence = "";
				for (char c: sentence.toCharArray()) {
					char[] temp = new char[1];
					temp[0] = c;
					newSentence += dictionary.get(new String(temp));
				}
				writer.println("Case #" + i + ": " + newSentence);
			}
			
			writer.close();
			fr.close();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	
	public static boolean canMatch(int score, int target) {
		if (score == 0)
			return target <= 0;
		if (score == 1 || score == 2)
			return target <= 1;
		if (score % 3 == 0){
			return score/3 >= target;
		} 
		return ((score/3) + 1 >= target);
	}
	
	public static boolean canMatchSpecial(int score, int target) {
		if (score == 0)
			return target <= 0;
		if (score == 1)
			return target <= 1;
		if (score == 2)
			return target <= 2;
		if (score % 3 == 1)
			return (score /3 + 1) >= target;
		return (score /3 + 2) >= target;
	}
	
	public static void dance() {
		try {
			FileReader fr = new FileReader("input.txt");
			BufferedReader reader = new BufferedReader(fr);
			PrintWriter writer = new PrintWriter("output.txt");
			
			int numCases = Integer.parseInt(reader.readLine());
			for (int i = 1; i <= numCases; i++) {
				StringTokenizer line = new StringTokenizer(reader.readLine(), " ");
				int numDancers = Integer.parseInt(line.nextToken());
				int numSurprising = Integer.parseInt(line.nextToken());
				int bestScore = Integer.parseInt(line.nextToken());
				List<Integer> scores = new LinkedList<Integer>();
				for (int j = 0; j < numDancers; j++)
					scores.add(Integer.parseInt(line.nextToken()));
				int count = 0;
				for (Integer score: scores) {
					if (canMatch(score, bestScore))
						count++;
					else if (canMatchSpecial(score, bestScore) && numSurprising > 0) {
						numSurprising--;
						count++;
					}
				}
				writer.println("Case #" + i + ": " + count);
			}
			
			writer.close();
			fr.close();
			
			
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	public static void main (String[] args) {
		//lame();
		dance();
	}
}