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

public class ProblemB {

	static ArrayList<int[]> triples = new ArrayList<int[]>();
	static int p = 0;
	static int s = 0;
	static int count = 0;

	public static void main(String args[]) {
		ReadInFile();
	}

	private static int parseLine(String str) {

		count = p = s = 0;
		triples.clear();

		String[] tokens = str.split("\\s+");

		int N = Integer.parseInt(tokens[0]);
		s = Integer.parseInt(tokens[1]);
		p = Integer.parseInt(tokens[2]);

		ArrayList<Integer> scores = new ArrayList<Integer>();
		for (int i = 0; i < N; i++)
			scores.add(Integer.parseInt(tokens[i + 3]));

		GenerateTriples(scores, s, p);

		UpdateTriples();

		return count;
	}

	private static void UpdateTriples() {
		for (int[] triple : triples) {
			int maxScore = Math.max(Math.max(triple[0], triple[1]), triple[2]);
			if (maxScore >= p)
				count++;
			else if (maxScore == p - 1 && s > 0 && triple[0] > 0
					&& triple[1] > 0 && triple[2] > 0) {
				count++;
				s--;
			}
		}
	}

	private static void GenerateTriples(ArrayList<Integer> scores, int s, int p) {
		for (int score : scores) {
			int d = score / 3;
			int[] triple = new int[3];
			triple[0] = triple[1] = triple[2] = d;

			if (score % 3 == 1)
				triple[0]++;
			if (score % 3 == 2)
				triple[0] = triple[1] = d + 1;

			triples.add(triple);
		}
	}

	private static void ReadInFile() {
		try {

			FileWriter ofstream = new FileWriter("c:/cygwin/out.txt");
			BufferedWriter out = new BufferedWriter(ofstream);

			// Open the file that is the first
			// command line parameter
			FileInputStream fstream = new FileInputStream("c:/cygwin/B-small-attempt0.in");
			// Get the object of DataInputStream
			DataInputStream in = new DataInputStream(fstream);
			BufferedReader br = new BufferedReader(new InputStreamReader(in));
			String strLine;
			// Read File Line By Line
			int i = 0;
			strLine = br.readLine();
			while ((strLine = br.readLine()) != null) {
				// Print the content on the console
				System.out.println(strLine);
				System.out.println("Case #" + (++i) + ": " + parseLine(strLine)
						+ "\n");
				out.write("Case #" + (i) + ": " + parseLine(strLine) + "\n");
			}
			// Close the input stream
			in.close();
			out.close();

		} catch (Exception e) {// Catch exception if any
			System.err.println("Error: " + e.getMessage());
		}
	}

}
