import java.util.*;
public class Test {
  public static void main(String[] args){
    Scanner in = new Scanner(System.in);
    int T = in.nextInt();

    for(int i = 1; i<=T; i++) {
      int n = in.nextInt();
      int s = in.nextInt();
      int p = in.nextInt();
      int result = 0;
      for(int j = 0; j<n; j++){
        int x = canAddUp(in.nextInt(), p);
        if(x == 0) {
          result++;
        } else if (x==1 && s > 0) {
          result++;
          s--;
        }
      }
      System.out.println("Case #"+i+": "+result);
    }
  }

  public static int canAddUp(int sum, int limit) {
    boolean flag = false;
    for(int i = 0; i<=sum; i++) {
      for(int j = 0; i+j <= sum; j++) {
        int k = sum-(i+j);
        int a = Math.abs(i-j);
        int b = Math.abs(i-k);
        int c = Math.abs(j-k);
        if(a > 2 || b > 2 || c> 2){
          continue;
        }

        if (i>=limit || j>=limit || k>=limit) {
          if(a < 2 && b < 2 && c < 2) {
            return 0;
          }else{
            flag = true;
          }
        }
      }
    }
    return (flag) ? 1 : 2;
  }
}

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.Writer;
import java.util.HashSet;
import java.util.Set;


public class q2 {
	
	static int n = 0, s = 0, p = 0;
	static int t[];
	
	public static void main(String args[]) throws Exception {
		String path = "./src/";
		String ifile = path + "B-large.in";
		String ofile = path + "B-large.out";
		int i = 0, j = 0;
		
		

		
		
		BufferedReader in = new BufferedReader(new FileReader(ifile));
		StringBuilder os = new StringBuilder();

		
		
		String line = null;
		int ln = 0;
		
		in.readLine();
		
		while ((line = in.readLine()) != null) {
			String vs[] = line.split(" ");
			
			n = Integer.parseInt(vs[0]);
			s = Integer.parseInt(vs[1]);
			p = Integer.parseInt(vs[2]);
			
			t = new int[vs.length - 3];
			for (i = 0; i + 3< vs.length; ++i)
				t[i] = Integer.parseInt(vs[i+3]);
			
			++ln;
			os.append(String.format("Case #%d: %d", ln, max()));
			os.append('\n');
		}
		
		in.close();
		
		
		Writer out = new BufferedWriter(new FileWriter(ofile));
		out.write(os.toString());
		out.close();
	}
	
	static int max() {
//		Set<Integer> csp = new HashSet<Integer>();
//		Set<Integer> csc = new HashSet<Integer>();
		
		int max = 0;
		int i = 0,j = 0;
		
		int ipn = 0;
		int pn = 0;
		int cn = 0;
		
		int min_p;
		int max_p;
		
		if (p == 1) {
			min_p = 1;
			max_p = 0;
		}	
		else {
			min_p = p * 3 - 4;
			max_p = (p - 1) * 3;
		} 
		
		for (i = 0; i < t.length; ++i) {

			
			if (t[i] < min_p)
				++ipn;
			else if (t[i] > max_p)
				++cn;
			else
				++pn;
			
//			a += ((t[i] % 3) == 2) ? 2 : 1;
//
//			if ( a > p )
//				cs.add(new Integer(t[i]));
		}

		if (s <= pn)
			max = s + cn;
		else if (s > pn)
			max = pn + cn;
		
		
		return max;
	}
	
}

