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.io.*;
import java.util.*;


public class Solution {
	
	public static int calc(int N, int S, int p, int[] t){
		int ret = 0;
		
		ArrayList<Integer> list = new ArrayList<Integer>();
		
		for(int i=0; i<t.length; i++){
			if(Math.ceil((double)t[i]/3) >= p){
				ret ++;
			}
			// surprisingåè£
			else{
				list.add(new Integer(t[i]));
			}
		}
		
		// surprisingåè£ãéé ã«ã½ã¼ã
		Collections.sort(list, new Comparator<Integer>(){
		      public int compare(Integer t1, Integer t2) {
		          return t2 - t1;
		        }
		      });
		
		for(Integer ii : list){
			if(S>0){
				// surprisingã§+1æä½ã§ããæ¡ä»¶
				//   - åè¨å¤ã2ä»¥ä¸
				//   - åè¨å¤ãæ§æãã3ã¤ã®æ°å¤ã®ãã¡ã3ã¤ãåãæ° ã¾ãã¯ å¤§ããæ¹ã®2ã¤ãåãæ°
				if(ii.intValue() >= 2 && (ii.intValue()%3 != 1)){
					// åè¨å¤ã3ã§å²ã£ãå¤ãåãä¸ãã¦æå¤§å¤ã¨ãã
					if(Math.ceil((double)ii.intValue()/3) >= p-1){
						//System.out.println("includes surprising " + ii.intValue() + "->" + (Math.ceil((double)ii.intValue()/3)+1) + "," + "other");
						ret ++;
						S --;
						if(S == 0){
							break;
						}
					}
				}
			}
		}
		
		return ret;
	}
	
	public static void main(String[] args){
        if(args.length == 0){
            System.exit(1);
        }

        try{
            FileReader fr = new FileReader(args[0]);
            BufferedReader br = new BufferedReader(fr);
            
            FileOutputStream fos = new FileOutputStream("output.out");
            OutputStreamWriter osw = new OutputStreamWriter(fos , "UTF-8");
            BufferedWriter bw = new BufferedWriter(osw);
            
            String tmp_str;
            
            tmp_str = br.readLine();
            
            int numOfCases = Integer.parseInt(tmp_str);
            int caseIndex = 0;

            while((tmp_str = br.readLine()) != null){
            	caseIndex++;

                StringTokenizer st = new StringTokenizer(tmp_str, " ");
                int numOfTokens = st.countTokens();
                String[] tokenOfLine = new String[numOfTokens];
                for(int i=0; i<numOfTokens; i++){
                	tokenOfLine[i] = st.nextToken();
                }
                
                int N = Integer.parseInt(tokenOfLine[0]);
                int S = Integer.parseInt(tokenOfLine[1]);
                int p = Integer.parseInt(tokenOfLine[2]);
                
                //System.out.println("N:" + N);
                //System.out.println("S:" + S);
                //System.out.println("p:" + p);
                
                int[] t = new int[N];
                for(int i=0; i<N; i++){
                	int j=i+3;
	                t[i] = Integer.parseInt(tokenOfLine[j]);
	                //System.out.println("t[" + i + "]:" + t[i]);
                }
                
                int ret = calc(N, S, p, t);
                
                System.out.println("Case #" + caseIndex + ": " + ret);
                
            	if(caseIndex==numOfCases){
                	bw.write("Case #" + caseIndex + ": " + ret);
            	}else{
                	bw.write("Case #" + caseIndex + ": " + ret + "\n");
            	}
            }
            br.close();
            bw.close();
            osw.close();
            fos.close();

 
        }
        catch(IOException e){
            e.printStackTrace();
            System.exit(1);
        }

	}
}
