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

public class DanceGooglers{
  public static void main(String[] args){
    try{
      FileReader fin = new FileReader(args[0]);
      BufferedReader txtFile = new BufferedReader(fin);
    
      //FileWriter fout = new FileWriter(args[1]);
      //BufferedWriter out = new BufferedWriter(fout);
			
      String line = null;     
      line = txtFile.readLine();
      int T = Integer.parseInt(line);
      //System.out.println(T);
      for(int i = 0; i < T; i ++){
        line = txtFile.readLine();
        StringTokenizer st = new StringTokenizer(line, " ");
        int N = Integer.parseInt(st.nextToken());
        int S = Integer.parseInt(st.nextToken());
        int p = Integer.parseInt(st.nextToken());
        int[] ts = new int[N];
        for(int i1 = 0; i1 < N; i1 ++)
            ts[i1] = Integer.parseInt(st.nextToken());
            
        int[][] notSurp = new int[N][3];
        int[][] surp = new int[N][3];
        boolean[] outOfRange = new boolean[N]; 
        for(int i1 = 0; i1 < N; i1 ++){
            int num = ts[i1];
            if(num % 3 == 0){
                notSurp[i1][0] = num/3; notSurp[i1][1] = num/3; notSurp[i1][2] = num/3;
                surp[i1][0] = num/3-1; surp[i1][1] = num/3; surp[i1][2] = num/3+1;
                if(surp[i1][0] < 0 || surp[i1][2] > 10)
                    outOfRange[i1] = true; 
                else
                    outOfRange[i1] = false; 
            }
            if(num % 3 == 1){
                notSurp[i1][0] = num/3; notSurp[i1][1] = num/3; notSurp[i1][2] = num/3+1;
                surp[i1][0] = num/3-1; surp[i1][1] = num/3+1; surp[i1][2] = num/3+1;
                if(surp[i1][0] < 0 || surp[i1][2] > 10)
                    outOfRange[i1] = true; 
                else
                    outOfRange[i1] = false; 
            }
            if(num % 3 == 2){
                notSurp[i1][0] = num/3; notSurp[i1][1] = num/3+1; notSurp[i1][2] = num/3+1;
                surp[i1][0] = num/3; surp[i1][1] = num/3; surp[i1][2] = num/3+2;
                if(surp[i1][2] > 10)
                    outOfRange[i1] = true; 
                else
                    outOfRange[i1] = false; 
            }
        }//for(int i1 = 0; i1 < N; i1 ++)
        
        int result = 0;
        for(int i1 = 0; i1 < N-1; i1 ++){
            for(int i2 = i1 + 1; i2 < N; i2 ++){
                if(surp[i1][2] > surp[i2][2]){
                    int tmp = surp[i1][0];
                    surp[i1][0] = surp[i2][0];
                    surp[i2][0] = tmp;
                    
                    tmp = surp[i1][1];
                    surp[i1][1] = surp[i2][1];
                    surp[i2][1] = tmp;
                    
                    tmp = surp[i1][2];
                    surp[i1][2] = surp[i2][2];
                    surp[i2][2] = tmp;
                    
                    tmp = notSurp[i1][0];
                    notSurp[i1][0] = notSurp[i2][0];
                    notSurp[i2][0] = tmp;
                    
                    tmp = notSurp[i1][1];
                    notSurp[i1][1] = notSurp[i2][1];
                    notSurp[i2][1] = tmp;
                    
                    tmp = notSurp[i1][2];
                    notSurp[i1][2] = notSurp[i2][2];
                    notSurp[i2][2] = tmp;
                    
                    boolean tmp2 = outOfRange[i1];
                    outOfRange[i1] = outOfRange[i2];
                    outOfRange[i2] = tmp2;                    
                }
            }//for
        }//for
        
        /*for(int i1 = 0; i1 < N; i1 ++){
            System.out.println(surp[i1][0]+" "+surp[i1][1]+" "+surp[i1][2]);
            System.out.println(notSurp[i1][0]+" "+notSurp[i1][1]+" "+notSurp[i1][2]);
        }*/
        
        int k = 1;
        for(int i1 = N-1; i1 >= 0; i1 --){
            if(k <= S && surp[i1][2] >= p && notSurp[i1][2] < p && outOfRange[i1] == false){
                result ++;
                k ++;
            }
            else if(notSurp[i1][2] >= p){ 
                result ++;
            }
        }
        
        System.out.println("Case #"+Integer.toString(i+1)+": "+Integer.toString(result));
        
        
      }//for(int i = 0; i < T; i ++)
    }//try
    catch(IOException e) {
	e.printStackTrace();
    }
    
    
  }
}
