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.File;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

public class B {
  static int[] arr = new int[32];
  
  public static void main(String[] args) throws Exception {
    Scanner s = new Scanner(new File("B.in"));
    PrintWriter out = new PrintWriter(new File("B.out"));
    
    int T = s.nextInt();
    for (int tc = 1; tc <= T; tc++) {
      out.print("Case #" + tc + ": ");
      int N = s.nextInt();
      int S = s.nextInt();
      int p = s.nextInt();
      
      Arrays.fill(arr, 0);
      for (int i = 0; i < N; i++) arr[s.nextInt()]++;
      int ans = 0;
      for (int i = Math.max(3 * p - 2, 0); i <= 30; i++) ans += arr[i];
      int potential = 0;
      if (3 * p - 4 >= 2) potential += arr[3 * p - 4];
      if (3 * p - 3 >= 2) potential += arr[3 * p - 3];
      System.out.println(potential);
      ans += Math.min(potential, S);
      out.println(ans);
    }
    out.close();
  }
}
