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

public class DancingWithTheGooglers
{
    public DancingWithTheGooglers()
    {
        Scanner inFile = null;
        try
        {
            inFile = new Scanner(new File("inputB.txt"));
        }
        catch(Exception e)
        {
            System.out.println("Problem opening input file. Exiting...");
			System.exit(0);
        }
        int t = inFile.nextInt();
        
        int [] results = new int [t];
        DancingWithTheGooglersMax [] rnc = new DancingWithTheGooglersMax[t];
        
        int i, j;
        int [] scores;
        int s, p;
        for(i = 0; i < t; i++)
        {
            scores = new int [inFile.nextInt()];
            s = inFile.nextInt();
            p = inFile.nextInt();
            for(j = 0; j < scores.length; j++)
                scores[j] = inFile.nextInt();
            
            rnc[i] = new DancingWithTheGooglersMax(i, scores, s, p, results);
            rnc[i].start();
        }
        inFile.close();
        
        boolean done = false;
        
        while(!done)
        {
            done = true;
            for(i = 0; i < t; i++)
                if(rnc[i].isAlive())
                {
                    done = false;
                    break;
                }
        }
        
        PrintWriter outFile = null;
        try
        {
            outFile = new PrintWriter(new File("outputB.txt"));
        }
        catch(Exception e)
        {
            System.out.println("Problem opening output file. Exiting...");
			System.exit(0);
        }
        
        for(i = 0; i < results.length; i++)
            outFile.printf("Case #%d: %d\n", i+1, results[i]);
        outFile.close();
    }
    
    public static void main(String [] args)
    {
        new DancingWithTheGooglers();
    }
    
    private class DancingWithTheGooglersMax extends Thread
    {
        int id;
        int s, p;
        int [] results, scores;
        
        public DancingWithTheGooglersMax(int i, int [] aScores, int aS, int aP,int [] res)
        {
            id = i;
            s = aS;
            p = aP;
            results = res;
            scores = aScores;
        }
        
        public void run()
        {
            int a = 0, b = 0;
            
            if(p == 0)
                results[id] = scores.length;
            else if(p == 1)
            {
                int y;
                y = 3*p - 3;
                
                for(int i = 0; i < scores.length; i++)
                    if(scores[i] > y)
                        a++;
                    else if(scores[i] > 0)
                        b++;
                
                b = Math.min(b, s);
                results[id] = a+b;
            }
            else
            {
                int y, z;
                y = 3*p - 3;
                z = 3*p - 5;
                
                for(int i = 0; i < scores.length; i++)
                    if(scores[i] > y)
                        a++;
                    else if(scores[i] > z)
                        b++;
                
                b = Math.min(b, s);
                results[id] = a+b;
            }
        }
    }
}
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.ArrayList;
import java.util.Scanner;
import java.io.BufferedWriter;

public class D {
	public static void main(String[] args) throws IOException {
		int n;

		InputStreamReader reader = new InputStreamReader(new FileInputStream(
				args[0]));
		BufferedReader read = new BufferedReader(reader);
		BufferedWriter write = new BufferedWriter(new OutputStreamWriter(
				new FileOutputStream(args[1])));

		// Scanner scan = new Scanner(System.in);
		n = Integer.parseInt(read.readLine());
		// n = scan.nextInt();
		for (int i = 0; i < n; i++) {
			String p = read.readLine();
			write.write("Case #" + (i + 1) + ": " + holy(p, read));
			write.newLine();
		}
		write.flush();
		write.close();
	}

	static int holy(String s, BufferedReader read) throws IOException {
	
            int [] value = new int [103];
            String p = s;
            int i = 0;
            int min_score = 0;
            int result = 0;
            
            
            while (p.indexOf(" ") != -1){
                int pemisah = p.indexOf(" ");
                int a = Integer.parseInt(p.substring(0 , pemisah));
                value [i] = a;
                i++;
                p = p.substring(pemisah+1);
            }
            
            value [i] = Integer.parseInt(p);
            i++;
            
            switch (value[2]) {
                case 0 :
                    min_score = 0 ;
                    break;
                case 1 :
                    min_score = 1 ;
                    break;
                case 2 :
                    min_score = 2 ;
                    break;
                case 3 :
                    min_score = 5 ;
                    break;
                case 4 :
                    min_score = 8 ;
                    break;
                case 5 :
                    min_score = 11 ;
                    break;
                case 6 :
                    min_score = 14 ;
                    break;
                case 7 :
                    min_score = 17 ;
                    break;
                case 8 :
                    min_score = 20 ;
                    break;
                case 9 :
                    min_score = 23 ;
                    break;
                case 10 :
                    min_score = 26 ;
                    break;
            }
            
            int surprising = value [1];
            
			if (value[2] == 0) {
				for (int j = 3; j < i; j++) {
					result++;
				}
			} else {
				for (int j = 3; j < i; j++) {

					if ((value[j] == min_score) || (value[j] == min_score + 1)) {
						if (surprising > 0) {
							result++;
							surprising--;
						}
					}	

					if (value[j] > min_score + 1) {
						result++;
					}
				}
			}
                        
            return result;

	}
}