import java.util.List;


public class Case implements Runnable {

	private int id;
	private String output;

	private int n;
	private int s;
	private int p;
	private List<Integer> g;

	public Case(int id) {
		this.id = id;
	}

	public Case(int id, int n, int s, int p, List<Integer> g) {
		super();
		this.id = id;
		this.n = n;
		this.s = s;
		this.p = p;
		this.g = g;
	}

	public String solve() {
		int res = 0;
		for (int googler : g) {
			int b = googler / 3;
			boolean div = googler % 3 == 0;
			if (b >= p) {
				res++;
				continue;
			}
			if (p == b+1) {
				if (div && s > 0 && b > 0) {
					res++;
					s--;
					continue;
				}
				if (!div) {
					res++;
					continue;
				}
			}
			if (p == b+2) {
				if (3*b+2 == googler && s > 0) {
					res++;
					s--;
				}
			}
		}
		return String.valueOf(res);
	}

	@Override
	public void run() {
		output = solve();
	}

	@Override
	public String toString() {
		return "Case #" + id + ": " + output;
	}

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

public class DancingGooglers {
	public static void main(String args[]) {
		try {
			String strFileName = args[0];
			BufferedReader bfReader = new BufferedReader(new FileReader(strFileName));
			long nTestCases = Integer.parseInt(bfReader.readLine());
			
			for(int testCaseCounter=0;testCaseCounter<nTestCases;testCaseCounter++) {
				StringTokenizer st = new StringTokenizer(bfReader.readLine());
				int N = Integer.parseInt(st.nextToken());
				int S = Integer.parseInt(st.nextToken());
				int p = Integer.parseInt(st.nextToken());
								
				int i=0;
				int t[] = new int[N];
				while(st.hasMoreTokens()) {
					t[i++]=Integer.parseInt(st.nextToken());
				}
				
				int p1 = (p*3)-3;
				int p2 = (p*3)-4;
				int px = (p*3)-2;
				int ret=0;
				int s=0;
				
				for(i=0;i<N;i++) {
					if((t[i]>=p)&&(t[i]==p1||t[i]==p2))
						s++;
					else if((t[i]>=p)&&(t[i]>=px))
						ret++;
				}
				
				if(s<=S)
					ret+=s;
				else
					ret+=S;
				System.out.println("Case #" + (testCaseCounter+1) + ": " + ret);
			}
			
		}
		catch(FileNotFoundException e) {
			System.out.println(e.getMessage());
		}
		catch(IOException e) {
			System.out.println(e.getMessage());
			e.printStackTrace();
		}
	}
}
