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();
  }


}

/**
 *
 * @author amit
 */
import java.io.*;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.StringTokenizer;
//import java.util.Arrays;
//import java.math.BigInteger;

public class GCJ {

    BufferedReader rin;
    BufferedWriter wout;
    int numCases;


    public String getNextInput() {
        try {
        	String line = rin.readLine();
        	String[] aVars = line.split(" ");
        	long count = 0;
        	long N = Long.parseLong(aVars[0]);
        	long S = Long.parseLong(aVars[1]);
        	long P = Long.parseLong(aVars[2]);
        	ArrayList<Long> gc = new ArrayList<Long>();
        	for (int i=0; i<N; i++) {
        		gc.add(Long.parseLong(aVars[i+3]));
        	}
        	Collections.sort(gc);
        	for (int i=gc.size()-1; i>=0; i--) {
        		long t1 = gc.get(i);
        		//System.out.println("\nnum: " + t1);
        		long t2 = (long) Math.ceil((double)t1/3.0); 
        		if (t1 ==1 && P==2) break;
        		if (t1 ==0 && P>0) break;
        		if (P<= t2) {
        			count ++;
        			//System.out.println("\nadded without S");
        		}
        		else if (S>0 && P<=t2+1) {
        			count ++;
        			S--;
        			//System.out.println("\nadded with S");
        		}
        		else break;
        	}
        		/*
        		long t = Long.parseLong(aVars[i+3]);
        		System.out.println("\nscore" + t);
        		if ((t%3)==2) {
        			System.out.println("mod2");
        			if (P <= t/3+1) {
        				count ++;
        			}
        		}
        		else if ((t%3)==1) {
        			System.out.println("mod1");
        			S--;
        			if (P <= t/3 +1) {
        				count++;
        			}
        		}
        		else {
        			gc.add(t);
        			System.out.println("mod3");
        		}
        	}
        	Collections.sort(gc);
        	if (!(gc.isEmpty())) {
	        	for (int i=gc.size()-1; i>=0; i--) {
	        		//System.out.println("\ni: " + i);
	        		long t1 = gc.get(i);
	        		if (P<=t1/3) {
	        			count ++;
	        		}
	        		else if (P<=t1/3+1) {
	        			count ++;
	        			S--;
	        		}
	        		else if (S>0) {
	        			System.out.println("\nError!");
	        		}
	        		else break;
	        	}
        	}*/
        	return Long.toString(count);
        } catch (IOException e) {
            System.out.println("File Error! Could not read line from file");
        }
        return null;
    }
    
    public void writeNextOutput(String s) {
        try {
            wout.write(s);
            wout.write("\n");
        } catch (IOException e) {
            System.out.println("Error! Could not write to the file!");
        }
    }

    public GCJ(String s1, String s2) {
        try {
            rin = new BufferedReader(
                    new FileReader(s1));
            wout = new BufferedWriter(new FileWriter(s2));
            numCases = Integer.parseInt(rin.readLine());

            for(int i=1; i <= numCases; i++){
                System.out.println("case#" + i);
                String sout = getNextInput();
                sout = "Case #" + Integer.toString(i) + ":" + " " + sout;
                writeNextOutput(sout);
                //System.out.println("case#" + i);
            }
            rin.close();
            wout.close();
        } catch (IOException e) {
            System.out.println("File error");
            System.exit(0);
        }
    }

    public static void main(String[] args) {/*
        if (args.length!=2) {
        System.out.println("Enter input file!");
        System.exit(0);
        }*/
        GCJ a = new GCJ("infile.txt", "out.txt");
    }
}
