package template;

import java.util.ArrayList;
import java.util.Map;
import java.util.HashMap;

public class TestCase {

    private boolean isSolved;
    private Object solution;
    private Map<String, Integer> intProperties;
    private Map<String, ArrayList<Integer>> intArrayProperties;
    private Map<String, ArrayList<ArrayList<Integer>>> intArray2DProperties;
    private Map<String, Double> doubleProperties;
    private Map<String, ArrayList<Double>> doubleArrayProperties;
    private Map<String, ArrayList<ArrayList<Double>>> doubleArray2DProperties;
    private Map<String, String> stringProperties;
    private Map<String, ArrayList<String>> stringArrayProperties;
    private Map<String, ArrayList<ArrayList<String>>> stringArray2DProperties;
    private Map<String, Boolean> booleanProperties;
    private Map<String, ArrayList<Boolean>> booleanArrayProperties;
    private Map<String, ArrayList<ArrayList<Boolean>>> booleanArray2DProperties;
    private Map<String, Long> longProperties;
    private Map<String, ArrayList<Long>> longArrayProperties;
    private Map<String, ArrayList<ArrayList<Long>>> longArray2DProperties;
    private int ref;
    private double time;

    public TestCase() {
        initialise();
    }

    private void initialise() {
        isSolved = false;
        intProperties = new HashMap<>();
        intArrayProperties = new HashMap<>();
        intArray2DProperties = new HashMap<>();
        doubleProperties = new HashMap<>();
        doubleArrayProperties = new HashMap<>();
        doubleArray2DProperties = new HashMap<>();
        stringProperties = new HashMap<>();
        stringArrayProperties = new HashMap<>();
        stringArray2DProperties = new HashMap<>();
        booleanProperties = new HashMap<>();
        booleanArrayProperties = new HashMap<>();
        booleanArray2DProperties = new HashMap<>();
        longProperties = new HashMap<>();
        longArrayProperties = new HashMap<>();
        longArray2DProperties = new HashMap<>();
        ref = 0;
    }

    public void setSolution(Object o) {
        solution = o;
        isSolved = true;
    }
    
    public Object getSolution() {
        if (!isSolved) {
            Utils.die("getSolution on unsolved testcase");
        }

        return solution;
    }

    public void setRef(int i) {
        ref = i;
    }
    public int getRef() {
        return ref;
    }

    public void setTime(double d) {
        time = d;
    }
    public double getTime() {
        return time;
    }
    
    public void setInteger(String s, Integer i) {
        intProperties.put(s, i);
    }
    
    public Integer getInteger(String s) {
        return intProperties.get(s);
    }

    public void setIntegerList(String s, ArrayList<Integer> l) {
        intArrayProperties.put(s, l);
    }

    public void setIntegerMatrix(String s, ArrayList<ArrayList<Integer>> l) {
        intArray2DProperties.put(s, l);
    }

    public ArrayList<Integer> getIntegerList(String s) {
        return intArrayProperties.get(s);
    }

    public Integer getIntegerListItem(String s, int i) {
        return intArrayProperties.get(s).get(i);
    }

    public ArrayList<ArrayList<Integer>> getIntegerMatrix(String s) {
        return intArray2DProperties.get(s);
    }
    
    public ArrayList<Integer> getIntegerMatrixRow(String s, int row) {
        return intArray2DProperties.get(s).get(row);
    }
    
    public Integer getIntegerMatrixItem(String s, int row, int column) {
        return intArray2DProperties.get(s).get(row).get(column);
    }

    public ArrayList<Integer> getIntegerMatrixColumn(String s, int column) {
        ArrayList<Integer> out = new ArrayList();
        
        for(ArrayList<Integer> row : intArray2DProperties.get(s)) {
            out.add(row.get(column));
        }
        return out;
    }


    public void setDouble(String s, Double i) {
        doubleProperties.put(s, i);
    }
    
    public Double getDouble(String s) {
        return doubleProperties.get(s);
    }

    public void setDoubleList(String s, ArrayList<Double> l) {
        doubleArrayProperties.put(s, l);
    }

    public void setDoubleMatrix(String s, ArrayList<ArrayList<Double>> l) {
        doubleArray2DProperties.put(s, l);
    }

    public ArrayList<Double> getDoubleList(String s) {
        return doubleArrayProperties.get(s);
    }

    public Double getDoubleListItem(String s, int i) {
        return doubleArrayProperties.get(s).get(i);
    }

    public ArrayList<ArrayList<Double>> getDoubleMatrix(String s) {
        return doubleArray2DProperties.get(s);
    }
    
    public ArrayList<Double> getDoubleMatrixRow(String s, int row) {
        return doubleArray2DProperties.get(s).get(row);
    }
    
    public Double getDoubleMatrixItem(String s, int row, int column) {
        return doubleArray2DProperties.get(s).get(row).get(column);
    }

    public ArrayList<Double> getDoubleMatrixColumn(String s, int column) {
        ArrayList<Double> out = new ArrayList();
        
        for(ArrayList<Double> row : doubleArray2DProperties.get(s)) {
            out.add(row.get(column));
        }
        return out;
    }

    
    public void setString(String s, String t) {
        stringProperties.put(s, t);
    }
    
    public String getString(String s) {
        return stringProperties.get(s);
    }

    public void setStringList(String s, ArrayList<String> l) {
        stringArrayProperties.put(s, l);
    }

    public void setStringMatrix(String s, ArrayList<ArrayList<String>> l) {
        stringArray2DProperties.put(s, l);
    }

    public ArrayList<String> getStringList(String s) {
        return stringArrayProperties.get(s);
    }

    public String getStringListItem(String s, int i) {
        return stringArrayProperties.get(s).get(i);
    }

    public ArrayList<ArrayList<String>> getStringMatrix(String s) {
        return stringArray2DProperties.get(s);
    }
    
    public ArrayList<String> getStringMatrixRow(String s, int row) {
        return stringArray2DProperties.get(s).get(row);
    }
    
    public String getStringMatrixItem(String s, int row, int column) {
        return stringArray2DProperties.get(s).get(row).get(column);
    }

    public ArrayList<String> getStringMatrixColumn(String s, int column) {
        ArrayList<String> out = new ArrayList();
        
        for(ArrayList<String> row : stringArray2DProperties.get(s)) {
            out.add(row.get(column));
        }
        return out;
    }

    
    public void setBoolean(String s, Boolean b) {
        booleanProperties.put(s, b);
    }
    
    public Boolean getBoolean(String s) {
        return booleanProperties.get(s);
    }

    public void setBooleanList(String s, ArrayList<Boolean> l) {
        booleanArrayProperties.put(s, l);
    }

    public void setBooleanMatrix(String s, ArrayList<ArrayList<Boolean>> l) {
        booleanArray2DProperties.put(s, l);
    }

    public ArrayList<Boolean> getBooleanList(String s) {
        return booleanArrayProperties.get(s);
    }

    public Boolean getBooleanListItem(String s, int i) {
        return booleanArrayProperties.get(s).get(i);
    }

    public ArrayList<ArrayList<Boolean>> getBooleanMatrix(String s) {
        return booleanArray2DProperties.get(s);
    }
    
    public ArrayList<Boolean> getBooleanMatrixRow(String s, int row) {
        return booleanArray2DProperties.get(s).get(row);
    }
    
    public Boolean getBooleanMatrixItem(String s, int row, int column) {
        return booleanArray2DProperties.get(s).get(row).get(column);
    }

    public ArrayList<Boolean> getBooleanMatrixColumn(String s, int column) {
        ArrayList<Boolean> out = new ArrayList();
        
        for(ArrayList<Boolean> row : booleanArray2DProperties.get(s)) {
            out.add(row.get(column));
        }
        return out;
    }

    public void setLong(String s, Long b) {
        longProperties.put(s, b);
    }
    
    public Long getLong(String s) {
        return longProperties.get(s);
    }

    public void setLongList(String s, ArrayList<Long> l) {
        longArrayProperties.put(s, l);
    }

    public void setLongMatrix(String s, ArrayList<ArrayList<Long>> l) {
        longArray2DProperties.put(s, l);
    }

    public ArrayList<Long> getLongList(String s) {
        return longArrayProperties.get(s);
    }

    public Long getLongListItem(String s, int i) {
        return longArrayProperties.get(s).get(i);
    }

    public ArrayList<ArrayList<Long>> getLongMatrix(String s) {
        return longArray2DProperties.get(s);
    }
    
    public ArrayList<Long> getLongMatrixRow(String s, int row) {
        return longArray2DProperties.get(s).get(row);
    }
    
    public Long getLongMatrixItem(String s, int row, int column) {
        return longArray2DProperties.get(s).get(row).get(column);
    }

    public ArrayList<Long> getLongMatrixColumn(String s, int column) {
        ArrayList<Long> out = new ArrayList();
        
        for(ArrayList<Long> row : longArray2DProperties.get(s)) {
            out.add(row.get(column));
        }
        return out;
    }

    

    


}

package qualification;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Comparator;


public class B {

	private static final char[] CASE = "Case #".toCharArray();

	public static void main(String[] args) throws Throwable {
//		in = System.in;
//		out = System.out;
//		in = new FileInputStream("in/B.in");
		in = new FileInputStream("in/B-small-attempt0.in");
		out = new PrintStream(new FileOutputStream("out/B.out"));
		
		int T = readInt();
		
		int[] t = new int[128];
		for (int test = 1; test <= T; test++) {
			int N = readInt();// number of googlers
			int S = readInt();// number of surprising triplets
			int p = readInt();// minimal result
			for (int i = 0; i < N; i++) {
				t[i] = readInt();
			}
			// TODO need to test it with 10's and 0's
//			Arrays.sort(t, 0, N);
			int result = 0;
			//for (int i = N-1; i >= 0; i--) {
			for (int i = 0; i < N; i++) {
				int v = t[i];
//				int aThird = v/3;
//				if (aThird >= p) {
//					result++;
//				} else if (aThird*3 < v && aThird+1 == p) {// for example: 5 6 6 or 5 5 6
//					result++;
//				} else if (S > 0 && aThird*3 == v && aThird*3 == (p-1)*3 && p > 1) {// 6 7 8 'anomally'
//					result++;
//					S--;
//				} else if (S > 0 && v == (p*3)-4 && p > 1) {// 6 6 8 'anomally'
//					result++;
//					S--;
//				} else {
//					break;// no more will do
//				}
				if (v >= (p*3) - 2) {
					result++;
				} else if (S>0 && v >= 2 && v >= (p*3)-4) {
					result++;
					S--;
				}
			}
			
			writeOut(CASE);
			writeOutNumber(test);
			writeOut(':');
			writeOut(' ');
			writeOutNumber(result);
			writeOutLn();
		}
		
		flush();

	}

	static InputStream in;
	static PrintStream out;
	
	static byte[] buffer = new byte[8192];
	static int pos;
	static int max;

	static final int maxOut = 8192;
	static byte[] output = new byte[maxOut];
	static int posOut = 0;
	
	static char[] tmpcharr = new char[128];

	static int pow2(int v) {
		return v * v;
	}

	static boolean reachedEndOfLine() throws Throwable {
		while (true) {
			int data = read();
			if (data == -1)
				return true;
			if (data == '\r' || data == '\n') {
				return true;
			}
			if (data == ' ') {
				continue;
			}
			pos--;
			return false;
		}
	}

	// COMPARISION FUNCTIONS

	static boolean isValidChar(int v) {
		// nao verifica o 'DELETE' (127)
		return (v & 0xE0) != 0;
	}

	static boolean isNum(int v) {
		return v >= '0' && v <= '9';
	}

	static boolean isLowercase(int cur) {
		return cur >= 'a' && cur <= 'z';
	}

	static boolean isUppercase(int cur) {
		return cur >= 'A' && cur <= 'Z';
	}

	// is a letter (alphabetic)
	static boolean isAlpha(int cur) {
		return isLowercase(cur) || isUppercase(cur);
	}

	// is alphanumeric (letters and numbers)
	static boolean isAlphaNum(int cur) {
		return isAlpha(cur) || isNum(cur);
	}

	static boolean isMinus(int cur) {
		return cur == '-';
	}

	static boolean isPlus(int cur) {
		return cur == '+';
	}

	// INPUT FUNCTIONS

	static void goToBeginOfNextWord() throws Throwable {
		int cur;
		// se for -1 já sai do método
		while ((cur = read()) != -1) {
			// se for um char válido então deixa o ponteiro nele
			if (cur > 32) {
				pos--;
				return;
			}
		}
	}

	// return the length of the string read
	static String readWord() throws Throwable {
		int len = 0;
		int cur;
		// descarta os espacos em branco primeiro
		while ((cur = read()) < 33) {
			if (cur == -1) return "";
		}

		tmpcharr[len++] = (char) cur;
		while ((cur = (char) read()) > 32) {
			tmpcharr[len++] = (char) cur;
		}

		return new String(tmpcharr, 0, len);
	}

	static void discardWord() throws Throwable {
		int cur;
		// descarta os espacos em branco primeiro
		while ((cur = read()) < 33) {
			if (cur == -1)
				return;
		}
		// descarta os valores 'validos'
		while ((cur = read()) > 32)
			;
	}

	static int readInt() throws Throwable {
		int cur;
		while (!isNum(cur = read()) && !isMinus(cur))
			if (cur == -1)
				return -1;
		int v = 0;
		boolean minus = false;
		if (isMinus(cur)) {
			minus = true;
			cur = read();
		}
		while (isNum(cur)) {
			v *= 10;
			v += (cur - '0');
			cur = read();
		}
		return minus ? -v : v;
	}

	static char readChar() throws Throwable {
		int cur;
		for (;;) {
			cur = read();
			if (cur == -1)
				return 0;
			if (cur == '\r' || cur == '\n' || cur == ' ')
				continue;

			return (char) cur;
		}
	}

	static long readLong() throws Throwable {
		int cur;
		while (!isNum(cur = read()) && !isMinus(cur))
			if (cur == -1)
				return -1;
		long v = 0;
		boolean minus = false;
		if (isMinus(cur)) {
			minus = true;
			cur = read();
		}
		while (isNum(cur)) {
			v *= 10;
			v += (cur - '0');
			cur = read();
		}
		return minus ? -v : v;
	}

	static boolean hasInput() throws Throwable {
		while (true) {
			int data = read();
			if (data == -1)
				return false;
			if ((data & 0xE0) != 0) {
				pos--;
				return true;
			}
		}
	}

	static int read() throws Throwable {
		if (pos >= max) {
			max = in.read(buffer);
			if (max < 0)
				return -1;
			pos = 0;
		}
		return buffer[pos++] & 0xff;
	}

	// OUTPUT FUNCTIONS

	// escreve um char

	static void writeOut(char c) {
		if (posOut >= maxOut) {
			writeOutToStream();
		}
		output[posOut++] = (byte) c;
	}

	// escreve a quebra de linha
	static void writeOutLn() {
		writeOut('\n');
	}

	// escreve um char[]
	static void writeOut(char[] cs) {
		writeOut(cs, 0, cs.length);
	}

	// escreve uma cadeia de caracteres
	static void writeOut(char[] chars, int offset, int length) {
		final int end = offset + length;
		for (int i = offset; i < end; i++) {
			writeOut(chars[i]);
		}
	}

	static void writeOutNumber(int value) {
		int len = 0;
		int pos = tmpcharr.length;
		if (value == 0) {
			writeOut('0');
			return;
		}
		boolean negative = value < 0;
		if (negative)
			value = -value;
		while (value > 0) {
			tmpcharr[--pos] = (char) ((value % 10) + '0');
			len++;
			value /= 10;
		}
		if (negative)
			writeOut('-');
		writeOut(tmpcharr, pos, len);
	}

	static void writeOutNumberAsBin(int num) {
		int len = 0;
		int pos = tmpcharr.length;
		if (num == 0) {
			writeOut('0');
			return;
		}
		while (num > 0) {
			tmpcharr[--pos] = ((num & 1) == 1) ? '1' : '0';
			len++;
			num >>>= 1;
		}
		writeOut(tmpcharr, pos, len);
	}

	static void flush() {
		writeOutToStream();
		out.flush();
	}

	// PRIVATE methods must be used only by the utility methods

	private static void writeOutToStream() {
		out.write(output, 0, posOut);
		posOut = 0;
	}

}