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

public class DancingWithGooglers {

  public static class Googlers {

    public int T;
    public int surp;
    public boolean surprising;
    public boolean pSurprising;
    public boolean antiSurprising;
    public boolean pAntiSurprising;

    public Googlers(int T, int surp) {
      this.T = T;
      this.surp = surp;
    }

    public void set(int a, int b, int c) {
      if (c >= 0 && (a + b + c) == T) {
        int diff = (Math.max(a, Math.max(b, c)) - Math.min(a, Math.min(b, c)));
        if (diff <= 2) {
          if (diff == 2) {
            if (a >= surp || b >= surp || c >= surp) {
              pSurprising = true;
            } else {
              surprising = true;
            }
          } else {
            if (a >= surp || b >= surp || c >= surp) {
              pAntiSurprising = true;
            } else {
              antiSurprising = true;
            }
          }
        }
      }
    }
  }

  public static void main(String... args) throws IOException {
//    BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    BufferedReader reader = new BufferedReader(new FileReader("B-large.in"));
//    PrintWriter writer = new PrintWriter(System.out);
    PrintWriter writer = new PrintWriter("B-large.out");

    int len, cases = Integer.parseInt(reader.readLine());
    List<Googlers> satisfied = new ArrayList<Googlers>();
    List<Googlers> unsatisfied = new ArrayList<Googlers>();
    String[] inputs;
    int N, S, p;
    for (int i = 1; i <= cases; i++) {
      inputs = reader.readLine().split(" ");
      p = Integer.parseInt(inputs[1]);
      S = Integer.parseInt(inputs[2]);
      satisfied.clear();
      unsatisfied.clear();
      for (int j = 3; j < inputs.length; j++) {
        int t = Integer.parseInt(inputs[j]);
        Googlers googlers = new Googlers(t, S);

        for (int k = 0; k <= 10; k++) {
          int till = k + 2 > 10 ? 10 : k + 2;
          for (int l = k; l <= till; l++) {
            googlers.set(k, l, (t - (k + l)));
          }
        }
        if (googlers.pAntiSurprising) {
          satisfied.add(googlers);
        } else {
          unsatisfied.add(googlers);
        }
      }
      int pSurprising = 0;
      if (p > 0) {
        for (Iterator<Googlers> iter = unsatisfied.iterator(); iter.hasNext(); ) {
          Googlers googlers = iter.next();
          if (googlers.pSurprising) {
            pSurprising++;
            iter.remove();
            p--;
            if (p <= 0) break;
          }
        }
      }
      if(p > 0){
        for (Iterator<Googlers> iter = unsatisfied.iterator(); iter.hasNext(); ) {
          Googlers googlers = iter.next();
          if (googlers.surprising) {
            iter.remove();
            p--;
            if (p <= 0) break;
          }
        }
      }
      if(p > 0){
        for (Iterator<Googlers> iter = satisfied.iterator(); iter.hasNext(); ) {
          Googlers googlers = iter.next();
          if (googlers.pSurprising) {
            iter.remove();
            pSurprising++;
            p--;
            if (p <= 0) break;
          }
        }
      }
      if(p > 0){
        for (Iterator<Googlers> iter = satisfied.iterator(); iter.hasNext(); ) {
          Googlers googlers = iter.next();
          if (googlers.surprising) {
            iter.remove();
            p--;
            if (p <= 0) break;
          }
        }
      }

      if(p > 0){
        writer.print("Case #" + i + ": 0");
      }else {
        writer.print("Case #" + i + ": " + (satisfied.size() + pSurprising));
      }
      writer.println();
    }
    writer.flush();
  }


}

import java.util.*;

public class Problem2 {
	public Problem2(){
		Scanner scan = new Scanner(System.in);
		int inputs = scan.nextInt();
		for(int i=1; i<=inputs; i++){
			int googlers = scan.nextInt();
			int sur = scan.nextInt();
			int bResult = scan.nextInt();
			int num = 0;
			int[] results = new int[googlers];
			for(int j=0; j<googlers; j++){
				results[j]=scan.nextInt();
			}
			num = calc(googlers, sur, bResult, results);
			System.out.println("Case #"+i+": "+num);
		}
	}
	
	public int calc(int g, int s, int bS, int[] r){
		int[][] score = new int[g][5];
		for(int i=0; i<g; i++){
			if(r[i]%3 == 0){
				score[i][0] = 0;
				score[i][1] = r[i]/3;
				score[i][2] = r[i]/3;
				score[i][3] = r[i]/3;
				score[i][4] = 1;
			}else{
				double h = r[i];
				h = h/3;
				if(Math.floor(h) == Math.round(h)){ //means the value is x.3333, should now add two rounded down and add one rounded up
					score[i][0] = 0;
					score[i][1] = (int)Math.floor(h);
					score[i][2] = (int)Math.floor(h);
					score[i][3] = (int)Math.ceil(h);
				}else{ //catches values with x.6666, should now add two rounded up and add one rounded down
					score[i][0] = 0;
					score[i][1] = (int)Math.floor(h);
					score[i][2] = (int)Math.ceil(h);
					score[i][3] = (int)Math.ceil(h);
					score[i][4] = 1;
				}
			}
			if(score[i][1]>=bS || score[i][2]>=bS || score[i][3]>=bS){
				score[i][0]=1;
			}
		}
		int x = 0;
			List<Integer> z = new ArrayList<Integer>();
			for(int i=0; i<g; i++){
				if(score[i][0] != 1){
					z.add(i);
					x++;
				}
			}
			int f = 0;
			for(int a:z){
				if(score[a][3] >= bS-1 && f<s && score[a][1]+score[a][2]+score[a][3]>1 && score[a][4]==1){
					f++;
				}
			}	
			x = x-f;
		return g-x;
	}
	
	public static void main(String[] args){
		new Problem2();
	}
}
