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

}
/* ==========================================================
 *  (C) Copyright 2007-present Facebook. All rights reserved.
 * ==========================================================
 */


import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;

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

/**
 * .
 *
 * @author
 */
public class Dancers {
    public static void main( String[] args ) throws NumberFormatException,
        IOException {
        final BufferedReader in =
            new BufferedReader( new FileReader(
                    "/Users/oded/a/ttt/src/in.txt" ) );
        final int numLines = Integer.parseInt( in.readLine() );

        for( int i = 0; i < numLines; i++ ) {
            handleLine( in.readLine(), i );
        }
    }

    private static void handleLine( String readLine, int lineNumber ) {
        String[] numbers       = readLine.split( " " );
        int      n             = Integer.parseInt( numbers[ 0 ] );
        int      s             = Integer.parseInt( numbers[ 1 ] );
        int      p             = Integer.parseInt( numbers[ 2 ] );
        int      results       = 0;
        int      thresholdNotS = p * 3 - 3 > 0 ? p * 3 - 3 : 0;
        int      thresholdS    = p * 3 - 5 > 0 ? p * 3 - 5 : 0;

        for( int i = 3; i < n + 3; i++ ) {
            int score = Integer.parseInt( numbers[ i ] );

            if( p == 0 ) {
                results++;
            } else if( score > ( thresholdNotS ) ) {
                results++;
            } else if( s > 0 && score > thresholdS ) {
                results++;
                s--;
            }
        }

        System.out.println( "Case #" + ( lineNumber + 1 ) + ": " + results );
    }
}
