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);
	}

}

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", "large");
		OutputFile outputFile = new OutputFile(inputFile);
		solve(inputFile, outputFile);
		outputFile.endFile();
		
	}
	
	
	
}
