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 B {
	public static void main (String [] args) {
				
		Scanner s = new Scanner(System.in);
		int T = s.nextInt();
		
        int[] normalBestScores = new int[]{
            0, //0: (0, 0, 0)
            1, //1: (1, 0, 0)
            1, //2: (1, 1, 0)
            1, //3: (1, 1, 1)
            2, //4: (2, 1, 1)
            2, //5: (2, 2, 1)
            2, //6: (2, 2, 2)
            3, //7: (3, 2, 2)
            3, //8: (3, 3, 2)
            3, //9: (3, 3, 3)
            4, //10: (4, 3, 3)
            4, //11: (4, 4, 3)
            4, //12: (4, 4, 4)
            5, //13: (5, 4, 4)
            5, //14: (5, 5, 4)
            5, //15; (5, 5, 5)
            6, //16: (6, 5, 5)
            6, //17: (6, 6, 5)
            6, //18: (6, 6, 6)
            7, //19: (7, 6, 6)
            7, //20: (7, 7, 6)
            7, //21: (7, 7, 7)
            8, //22: (8, 7, 7)
            8, //23: (8, 8, 7)
            8, //24: (8, 8, 8)
            9, //25: (9, 8, 8)
            9, //26: (9, 9, 8)
            9, //27: (9, 9, 9)
            10, //28: (10, 9, 9)
            10, //29: (10, 10, 9)
            10 //30: (10, 10, 10)
        };
        
        int[] surpriseBestScores = new int[] {
            -1, //0: None
            -1, //1: None
            2, //2: (2, 0, 0)
            2, //3: (2, 1, 0)
            2, //4: (2, 2, 0)
            3, //5: (3, 1, 1)
            3, //6: (3, 2, 1)
            3, //7: (3, 3, 1)
            4, //8: (4, 2, 2)
            4, //9: (4, 3, 2)
            4, //10: (4, 4, 2)
            5, //11: (5, 3, 3)
            5, //12: (5, 4, 3)
            5, //13: (5, 5, 3)
            6, //14: (6, 4, 4)
            6, //15: (6, 5, 4)
            6, //16: (6, 6, 4)
            7, //17: (7, 5, 5)
            7, //18: (7, 6, 5)
            7, //19: (7, 7, 5)
            8, //20: (8, 6, 6)
            8, //21: (8, 7, 6)
            8, //22: (8, 8, 6)
            9, //23: (9, 7, 7)
            9, //24: (9, 8, 7)
            9, //25: (9, 9, 7)
            10, //26: (10, 8, 8)
            10, //27: (10, 9, 8)
            10, //28: (10, 10, 8)
            -1, //29: None
            -1 //30: None
        };
        
		for (int t = 1; t <= T; t++) {
			int N = s.nextInt();
            int S = s.nextInt();
            int p = s.nextInt();
            int[] tp = new int[N];
            for (int i = 0; i < N; i++)
                tp[i] = s.nextInt();
			Arrays.sort(tp);
            int ans = 0;
            for (int i = N-1; i >= 0; i--) {
                if (normalBestScores[tp[i]] >= p) {
                    ans++;
                } else if (S > 0 && tp[i] >= 2 && tp[i] <= 28) {
                    S--;
                    if (surpriseBestScores[tp[i]] >= p) {
                        ans++;
                    }
                }            
            }
            
			System.out.println("Case #" + t + ": "+ans);
		}
	}
}