import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;


public class Dancing {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		// read input file
		File file = new File("B-small-attempt4.in");
		//File file = new File("input.txt");
		BufferedReader br = new BufferedReader(new FileReader(file));
		String ln = "";
		int count = Integer.parseInt(br.readLine());

		// write output file
		File out = new File("outB.txt");
		BufferedWriter bw = new BufferedWriter(new FileWriter(out));
		
		int y = 0;
		for (int i=0; i < count; i++){
			ln = br.readLine();
			y = getY(ln);
			bw.write("Case #" + (i+1) + ": " + y);
			bw.newLine();
		}
		bw.close();
	}
	
	private static int getY(String str) {
		String[] data = str.split(" ");
		int n = Integer.parseInt(data[0]);
		int s = Integer.parseInt(data[1]);
		int p = Integer.parseInt(data[2]);
		int[] t = new int[n];
		for (int i=0; i < n; i++){
			t[i] = Integer.parseInt(data[i+3]);
		}
		int y = 0;
		int base = 0;
		for(int j=0; j < t.length; j++){
			base = t[j] / 3;
			if(base >= p) { y++; }
			else if(base == p-1){
				if(t[j] - (base+p) > base-1 && t[j] > 0){
					y++;
				} else if(s>0 && t[j] - (base+p) > base-2 && t[j] > 0){
					s -= 1;
					y++;
				}
			} else if(base == p-2){
				if(s > 0 && t[j] - (base+p) > base-1 && t[j] > 0){
					s -= 1;
					y++;
				}
			}
		}
		
		return y;
	}

}

package _2012.QualificationRound.B;

import java.util.ArrayList;

import Utils.InputFile;
import Utils.OutputFile;

public class B {

	
	
	
	
	private static void solve(InputFile inputFile, OutputFile outputFile){
		
		int nbCases = Integer.parseInt(inputFile.getNextLine());
		
		for(int caseNumber = 0; caseNumber < nbCases; caseNumber++){
			String[] line = inputFile.getNextLine().split(" ");
			int nbGooglers = Integer.parseInt(line[0]);
			int nbSurprising = Integer.parseInt(line[1]);
			int noteSeuil = Integer.parseInt(line[2]);
			int result = 0;
			
			for(int i = 3; i < 3+nbGooglers; i++){
				int totalNote = Integer.parseInt(line[i]);
				int maxWithoutSurprise = -1;
				int maxWithSurprise = -1;
				
				if(totalNote == 0){
					maxWithoutSurprise = 0;
					maxWithSurprise = -1;
				}
				else if(totalNote == 1){
					maxWithoutSurprise = 1;
					maxWithSurprise = -1;
				}
				else if(totalNote == 2){
					maxWithoutSurprise = 1;
					maxWithSurprise = 2;
				}
				else if(totalNote == 3){
					maxWithoutSurprise = 1;
					maxWithSurprise = 2;
				}
				else if(totalNote == 4){
					maxWithoutSurprise = 2;
					maxWithSurprise = 2;
				}
				else if(totalNote == 5){
					maxWithoutSurprise = 2;
					maxWithSurprise = 3;
				}
				else if(totalNote == 6){
					maxWithoutSurprise = 2;
					maxWithSurprise = 3;
				}
				else if(totalNote == 7){
					maxWithoutSurprise = 3;
					maxWithSurprise = 3;
				}
				else if(totalNote == 8){
					maxWithoutSurprise = 3;
					maxWithSurprise = 4;
				}
				else if(totalNote == 9){
					maxWithoutSurprise = 3;
					maxWithSurprise = 4;
				}
				else if(totalNote == 10){
					maxWithoutSurprise = 4;
					maxWithSurprise = 4;
				}
				else if(totalNote == 11){
					maxWithoutSurprise = 4;
					maxWithSurprise = 5;
				}
				else if(totalNote == 12){
					maxWithoutSurprise = 4;
					maxWithSurprise = 5;
				}
				else if(totalNote == 13){
					maxWithoutSurprise = 5;
					maxWithSurprise = 5;
				}
				else if(totalNote == 14){
					maxWithoutSurprise = 5;
					maxWithSurprise = 6;
				}
				else if(totalNote == 15){
					maxWithoutSurprise = 5;
					maxWithSurprise = 6;
				}
				else if(totalNote == 16){
					maxWithoutSurprise = 6;
					maxWithSurprise = 6;
				}
				else if(totalNote == 17){
					maxWithoutSurprise = 6;
					maxWithSurprise = 7;
				}
				else if(totalNote == 18){
					maxWithoutSurprise = 6;
					maxWithSurprise = 7;
				}
				else if(totalNote == 19){
					maxWithoutSurprise = 7;
					maxWithSurprise = 7;
				}
				else if(totalNote == 20){
					maxWithoutSurprise = 7;
					maxWithSurprise = 8;
				}
				else if(totalNote == 21){
					maxWithoutSurprise = 7;
					maxWithSurprise = 8;
				}
				else if(totalNote == 22){
					maxWithoutSurprise = 8;
					maxWithSurprise = 8;
				}
				else if(totalNote == 23){
					maxWithoutSurprise = 8;
					maxWithSurprise = 9;
				}
				else if(totalNote == 24){
					maxWithoutSurprise = 8;
					maxWithSurprise = 9;
				}
				else if(totalNote == 25){
					maxWithoutSurprise = 9;
					maxWithSurprise = 9;
				}
				else if(totalNote == 26){
					maxWithoutSurprise = 9;
					maxWithSurprise = 10;
				}
				else if(totalNote == 27){
					maxWithoutSurprise = 9;
					maxWithSurprise = 10;
				}
				else if(totalNote == 28){
					maxWithoutSurprise = 10;
					maxWithSurprise = 10;
				}
				else if(totalNote == 29){
					maxWithoutSurprise = 10;
					maxWithSurprise = -1;
				}
				else if(totalNote == 30){
					maxWithoutSurprise = 10;
					maxWithSurprise = -1;
				}
				if(maxWithoutSurprise >= noteSeuil){
					result++;
				} else if(maxWithSurprise  >= noteSeuil && nbSurprising > 0){
					result++;
					nbSurprising--;
				}
				
			}
			
			
			String resultString = "" + result;
			
			outputFile.writeResult(resultString);
			
		}
		
		
		
		
		
	}
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	public static void main(String[] args) {
		
		InputFile inputFile = new InputFile("B", "small-attempt1");
		OutputFile outputFile = new OutputFile(inputFile);
		solve(inputFile, outputFile);
		outputFile.endFile();
		
	}
	
	
	
}
