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 DancingWithTheGooglers
{
   static int surprise, target;
   static int [] scores;
   static int numGooglers;
   
   static int [][] matrix;
   public static void main(String[] args) throws IOException
   {
      Scanner scan = new Scanner(new File("b_large.in"));
      
      int numCases = scan.nextInt();
      for (int z = 1; z <= numCases; z++)
      {
         numGooglers = scan.nextInt();
         surprise = scan.nextInt();
         target = scan.nextInt();
         
         scores = new int[numGooglers];
         for (int i = 0; i < numGooglers; i++)
            scores[i] = scan.nextInt();
         
         matrix = new int[numGooglers][surprise+1];
         for (int [] arr : matrix)
            Arrays.fill(arr, -1);
         
         int max = magic(0, surprise);
         
         System.out.println("Case #"+z+": " + max);
      }
   }
   
   static int magic(int pos, int surpriseLeft)
   {
      if (surpriseLeft < 0)
         return -1000000;
      if (pos == numGooglers)
      {
         if (surpriseLeft != 0)
            return -1000000;
         else
            return 0;
      }
      
      if (matrix[pos][surpriseLeft] >= 0)
         return matrix[pos][surpriseLeft];

      int best = 0;
      for (int i = 0; i <= 10; i++)
      {
         for (int j = Math.max(i-2, 0); j <= Math.min(10,i+2); j++)
         {
            for (int k = Math.max(i-2, 0); k <= Math.min(10,i+2); k++)
            {
               if (Math.abs(i-j) > 2 || Math.abs(j-k) > 2 || Math.abs(i-k) > 2)
                  continue;
               if (i + j + k != scores[pos])
                  continue;

               int score = 0;
               if (i >= target || j >= target || k >= target)
                  score = 1;
               
               if (Math.abs(i-j) > 1 || Math.abs(j-k) > 1 || Math.abs(i-k) > 1)
                  best = Math.max(best, score+magic(pos+1, surpriseLeft-1));
               else
                  best = Math.max(best, score+magic(pos+1, surpriseLeft));
            }
         }
      }
      matrix[pos][surpriseLeft] = best;
      return best;
   }
}
