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.File;
import java.io.FileNotFoundException;
import java.util.Arrays;
import java.util.Scanner;


public class Main {

	public static int findX(int x, int y, int z, int score)
	{
		int a = -1;
		
		a = (score - x-y-z)/3;
		if(a+x + a+y + a+z == score)
			return a+x;
		else
			return -1;
	}
	
	public static int findValid(int score, int max) {
		int x=-1, y=-1,z=-1;
		int evalid = 0;
		/*Case: x x x*/
		if( (x = findX(0,0,0, score))!= -1 && evalid != 2)
		{
			y=z=x;
			if(z >= max)
				evalid = 2;
			else
				evalid = 1;
		}
	
		/*Case: x x x+1*/
		if( (x = findX(0,0,1, score))!= -1 && evalid !=2)
		{
			y=x;
			z=x+1;
			if(z >= max)
				evalid = 2;
			else
				evalid = 1;
		}
		
		/*Case: x x+1 x+1*/
		if( (x = findX(0,1,1, score))!= -1 && evalid != 2)
		{
			y=x+1;
			z=x+1;
			if(z >= max)
				evalid = 2;
			else
				evalid = 1;
		}
		return evalid;
	}
	
	public static int findSurprised(int score, int max) {
		int x=-1, y=-1,z=-1;
		int evalid = 0;
		/*Case: x x x+2*/
		if( (x = findX(0,0,2, score))!= -1 && evalid != 2)
		{
			y=x;
			z=x+2;
			if(z >= max)
				evalid = 2;
			else
				evalid = 1;
		}
	
		/*Case: x x+1 x+2*/
		if( (x = findX(0,1,2, score))!= -1 && evalid !=2)
		{
			y=x+1;
			z=x+2;
			if(z >= max)
				evalid = 2;
			else
				evalid = 1;
		}
		
		/*Case: x x+2 x+2*/
		if( (x = findX(0,2,2, score))!= -1 && evalid != 2)
		{
			y=x+2;
			z=x+2;
			if(z >= max)
				evalid = 2;
			else
				evalid = 1;
		}
		return evalid;
	}
	
	public static void fillOptions(int[] scores, int[] valid, int[]surprised, int max )
	{
		for(int i = 0; i< scores.length; i++)
		{
			valid[i] = findValid(scores[i], max);
			surprised[i] = findSurprised(scores[i], max);
			valid[i] = valid[i]*10 + surprised[i];
		}
	}
	
	public static int findNextSerprised(int[] valid)
	{
		int val =0;
		Arrays.sort(valid);
		int index = Arrays.binarySearch(valid, 2);
		if(index < 0)
			index = Arrays.binarySearch(valid, 12);
		if(index < 0)
			index = Arrays.binarySearch(valid, 22);
		if(index < 0)
			index = Arrays.binarySearch(valid, 01);
		if(index < 0)
			index = Arrays.binarySearch(valid, 11);
		if(index < 0)
			index = Arrays.binarySearch(valid, 21);
		if(index >= 0)
		{
			val = valid[index];
			valid[index] = 0;
		}
		return val;
	}
	
	public static void runCase (int[] scores, int S, int max, int caseNum)
	{
		int[] valid = new int[scores.length];
		int[] surprised = new int[scores.length];
		int count =0;
		fillOptions(scores, valid, surprised, max);
		for(int i =0; i< S; i++)
		{
			int val = findNextSerprised(valid);
			if(val%10 == 2)
				count++;
		}
		for(int i=0; i< scores.length; i++)
			if(valid[i] >= 20)
				count++;
		System.out.print("Case #" +caseNum + ": "+ count + "\n");
	}
	
	/**
	 * @param args
	 * @throws FileNotFoundException 
	 */
	public static void main(String[] args) throws FileNotFoundException {
		if(args.length != 1)
		{
			System.out.print("Please enter file name!\n");
			return;
		}
		File fileName = new File(args[0]);
	    Scanner inFile = new Scanner(fileName);
	    int T = inFile.nextInt();
		for(int i=0; i < T; i++)
		{
			int N = inFile.nextInt();
			int S = inFile.nextInt();
			int max = inFile.nextInt();
			
			int[] scores = new int[N];
			for(int j=0; j<N; j++)
				scores[j]=inFile.nextInt();
			
			runCase(scores, S, max, i+1);	
		}
		
		
	}

}
