/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package IO;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
    
/**
 * 
 * @author dannocz
 */
public class InputReader {
    
    public static Input readFile(String filename){
        try {
              
              /*  Sets up a file reader to read the file passed on the command
          77        line one character at a time */
              FileReader input = new FileReader(filename);
              
              /* Filter FileReader through a Buffered read to read a line at a
                 time */
              BufferedReader bufRead = new BufferedReader(input);
              
              String line;    // String that holds current file line
              int count = 0;  // Line number of count 
              ArrayList<String> cases= new ArrayList<String>();
              
              // Read first line
              line = bufRead.readLine();
              int noTestCases=Integer.parseInt(line);
              count++;
              
              // Read through file one line at time. Print line # and line
              while (count<=noTestCases){
                  //System.out.println("Reading. "+count+": "+line);
                  line = bufRead.readLine();
                  cases.add(line);
                  count++;
              }
              
              bufRead.close();
              
              return new Input(noTestCases,cases);
              
          }catch (ArrayIndexOutOfBoundsException e){
              /* If no file was passed on the command line, this expception is
              generated. A message indicating how to the class should be
              called is displayed */
              e.printStackTrace();        
  
          }catch (IOException e){
              // If another exception is generated, print a stack trace
              e.printStackTrace();
          }
        
        return null;
          
      }// end main
    }

import java.util.*;
import java.io.*;

public class dancers {
	public static int test(int[] n){
		int counter = 0;
		int counter2 = 0;
		for(int i = 3; i < n[0] + 3; i++){
			if(n[i] >= (n[2]*3 - 2)){
				counter++;
			} else if((n[i] < n[2]*3 - 2) && (n[i] >= n[2]*3 - 4)){
				if((n[2]*3-4 < 0) && n[i] == 0){
					continue;
				}
				counter2++;
			}
		}
		
		if(counter2 <= n[1]){
			counter += counter2;
		} else{
			counter += + n[1];
		}
		
		return counter;
	}
	public static void main(String[] args) throws IOException{
		Scanner reader = new Scanner(new File("dancers.in"));
		PrintWriter out = new PrintWriter(new File("dancers.out"));
		
		int n = reader.nextInt();
		int[][] set = new int[n][103];
		for(int i = 0; i < n; i++){
			set[i][0] = reader.nextInt();
			for(int j = 1; j < set[i][0] + 3; j++){
				set[i][j] = reader.nextInt();
			}
		}
		int[] res = new int[n];
		for(int i = 0; i < n; i++){
			res[i] = test(set[i]);
			out.println("Case #" + (i+1) + ": " + res[i]);
		}
		
		out.close();
		System.exit(0);
	}
}