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.BufferedReader;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;


public class jam {

	public static void main(String args[])
	{
		ArrayList<String> inp=read_fil("D:\\google_Jam\\B-large.in");
		//		ArrayList<String> inp=read_fil("D:\\google_Jam\\A-large-practice.in");
		int lin_num=0;
		int T=Integer.valueOf(inp.get(lin_num));
		lin_num++;

		for(int kk=0;kk<T;kk++){

			String lin=inp.get(lin_num);
			lin_num++;
			String[] lins=lin.split(" ");
			int N=Integer.valueOf(lins[0]);
			int S=Integer.valueOf(lins[1]);
			int p=Integer.valueOf(lins[2]);
			int[] t=new int[N];
			int y=0;
			
			for(int i=0;i<N;i++){
				t[i]=Integer.valueOf(lins[i+3]);
			}
			for(int i=0;i<N;i++){
				int s1=0;int s2=0;int s3=0;
				while((s1+s2+s3)<t[i] && s1<=10 && s2<=10 && s3<=10){
					if(s3<10) s3++;
					if((s1+s2+s3)==t[i]) break;
					if(s2<10) s2++;
					if((s1+s2+s3)==t[i]) break;
					if(s1<10) s1++;
					if((s1+s2+s3)==t[i]) break;
				}
				if(s1+s2+s3!=t[i]) continue;
				int max=getmax(s1,s2,s3);
				if(max>=p){
					y++;
					continue;
				}else if(S>0 && s2==s3){
					s3++;
					s2--;
					if(s1+s2+s3==t[i] && s3>=p && s3>=p && s1>=0 && s2>=0 && s3>=0){
						S--;
						y++;
						continue;
					}
				}
				
			}
			if(S>0){
				y=0;
				for(int i=0;i<N;i++){
					int s1=0;int s2=0;int s3=0;
					while((s1+s2+s3)<t[i] && s1<=10 && s2<=10 && s3<=10){
						if(s3<10) s3++;
						if((s1+s2+s3)==t[i]) break;
						if(s2<10) s2++;
						if((s1+s2+s3)==t[i]) break;
						if(s1<10) s1++;
						if((s1+s2+s3)==t[i]) break;
					}
					if(s1+s2+s3!=t[i]) continue;
					
					if(S>0 && s2==s3){
						s3++;
						s2--;
						if(s1+s2+s3==t[i] && s3>=p && s1>=0 && s2>=0 && s3>=0){
							S--;
							y++;
							continue;
						}
					}else{
						int max=getmax(s1,s2,s3);
						if(max>=p){
							y++;
							continue;
						}
					}
					
				}
			}
			
			writeFile("Case #"+(kk+1)+": "+y);


		}


	}


	private static int getmax(int s1, int s2, int s3) {
		int max=0;
		if(max<s1) max=s1;
		if(max<s2) max=s2;
		if(max<s3) max=s3;
		return max;
	}


	public static ArrayList<String> read_fil(String file){  
		ArrayList<String> arr=new ArrayList<String>(); 
		try{

			FileInputStream fstream = new FileInputStream(file);

			DataInputStream in = new DataInputStream(fstream);
			BufferedReader br = new BufferedReader(new InputStreamReader(in));
			String strLine;

			while ((strLine = br.readLine()) != null)   {
				arr.add(strLine);
			}

			in.close();
		}catch (Exception e){
			System.err.println("Error: " + e.getMessage());
		}
		return arr;
	}

	public static void writeFile(String ss) {
		String fileName = "D:\\google_Jam\\Output.txt";

		try {
			FileWriter writer = new FileWriter(fileName,true);
			writer.write(ss);
			writer.write('\n');
			writer.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

}