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.awt.List;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Vector;

import javax.swing.JFrame;
import javax.swing.JTextField;

public class Test{
	public static void main(String[] args) {
	try{
		BufferedReader buff = new BufferedReader(new InputStreamReader(System.in));
		String T = buff.readLine();
		for(int q=0;q<Integer.parseInt(T);q++){
			String inp = buff.readLine();
			String arr[] = inp.split(" ");
			int N = Integer.parseInt(arr[0]);
			String S = arr[1];
			int s_int = Integer.parseInt(S);
			int p = Integer.parseInt(arr[2]);
			int inp_arr[] = new int[N];
			for(int l=0;l<N;l++)
				inp_arr[l] = Integer.parseInt(arr[l+3]);
			Vector<data> list = new Vector<data>();
			for(int a:inp_arr){
				if(a%3 == 0){
					int special_arr[] = new int[3];
					special_arr[0] = a/3-1;
					special_arr[1] = a/3;
					special_arr[2] = a/3+1;
					int normal_arr[] = new int[3];
					normal_arr[0] = a/3;
					normal_arr[1] = a/3;
					normal_arr[2] = a/3;
					data d = new data();
					d.set_normal_arr(normal_arr);
					d.set_special_arr(special_arr);
					list.add(d);
					
				}
				else if(a%3 == 1){
					int special_arr[] = new int[3];
					special_arr[0] = a/3-1;
					special_arr[1] = a/3+1;
					special_arr[2] = a/3+1;
					int normal_arr[] = new int[3];
					normal_arr[0] = a/3;
					normal_arr[1] = a/3;
					normal_arr[2] = a/3+1;
					data d = new data();
					d.set_normal_arr(normal_arr);
					d.set_special_arr(special_arr);
					list.add(d);
					
				}
				else{
					int special_arr[] = new int[3];
					special_arr[0] = a/3;
					special_arr[1] = a/3;
					special_arr[2] = a/3+2;
					int normal_arr[] = new int[3];
					normal_arr[0] = a/3;
					normal_arr[1] = a/3+1;
					normal_arr[2] = a/3+1;
					data d = new data();
					d.set_normal_arr(normal_arr);
					d.set_special_arr(special_arr);
					list.add(d);
					
				}
			}
			Iterator iter = list.iterator();
			int count =0;
			while(iter.hasNext()){
				data d = (data)iter.next();
				System.out.println("p:" + p+"s:"+s_int+" " + d.normal_arr[0] + " " +d.normal_arr[1] + " " + d.normal_arr[2] + " " +d.special_arr[0] + " " +d.special_arr[1] + " " +d.special_arr[2]);
				if(p <= d.get_largest_normal()){
					//TODO  count++
					count++;
				}
				else{
					if(s_int!=0){
						if(p <= d.get_largest_special()){
							//TODO count++ and s_int--
							count++;
							s_int--;
						}
						else{
							//System.out.println("Untrue for both special as well as normal");
						}
					}
				}
			}
		System.out.println("Case #" + (q+1) + ": " + count);
		}
	}catch(Exception e){System.out.println(e);}
	}
}
class data{
	int special_arr[];
	int normal_arr[];
	void set_special_arr(int arr[]){special_arr = arr;}
	void set_normal_arr(int arr[]){normal_arr = arr;}
	int[] get_special_arr(){return special_arr;}
	int[] get_normal_arr(){return normal_arr;}
	
	int get_largest_special(){if(special_arr[0] < 0 || special_arr[2]>10)return -1;return special_arr[2];}
	
	int get_largest_normal(){if(normal_arr[0] < 0 || normal_arr[2]>10)return -1;return normal_arr[2];}
	
}