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;
            }
        }
    }
}
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package dancing.with.the.googlers;

import java.io.*;
import java.util.ArrayList;
import java.util.StringTokenizer;

/**
 *
 * @author Abhishek
 */
public class DancingWithTheGooglers {

    /**
     * @param args the command line arguments
     */
    
    static int NoOfGooglers;
    static int surprisingResults;
    static int pi;
    static int count;
    private static String  inputFile = "F:/B-large.in";

    private static String outputFile = "F:/Output.txt";
    
    public static void main(String[] args) {
        // TODO code application logic here
         count = 0;
         readFile();
    }
    
     public static void readFile()
    {
        int totalLines =0;
        try 
        {
            FileInputStream fis = new FileInputStream(inputFile);
            DataInputStream dis = new DataInputStream(fis);
            BufferedReader br = new BufferedReader(new InputStreamReader(dis));
            ArrayList<Integer> scores = new ArrayList<Integer>();
            String str;
            StringTokenizer st;
            
            while( (str = br.readLine()) != null) 
            {
                NoOfGooglers = -1;
                surprisingResults = -1;
                pi = -1;
                scores.clear();
                st = new StringTokenizer(str, " \n");
                scores.clear();
                while( st.hasMoreTokens())
                {
                    if( totalLines == 0 )
                    {
                        totalLines = Integer.parseInt(str);
                        break;
                    }
                    if( NoOfGooglers == -1)
                    {
                        NoOfGooglers = Integer.parseInt(st.nextToken());
                        continue;
                    }
                    if(surprisingResults == -1)
                    {
                        surprisingResults = Integer.parseInt(st.nextToken());
                        continue;
                    }
                    if(pi == -1)
                    {
                        pi = Integer.parseInt(st.nextToken());
                        continue;
                    }
                    scores.add(Integer.parseInt(st.nextToken()));
                }
                if ( pi != -1)
                {
                    int passPi = findProbabilityPi(NoOfGooglers, surprisingResults, pi, scores);
                    writeFile(passPi);
                }
            }
        }
        catch(IOException e)
        {
            System.out.println("error is " +e.getMessage());
        }
    }
     
     public static void writeFile(int passPi)
    {
        String line="";
        try{
            // Create file 
            FileWriter fstream = new FileWriter(outputFile,true);
            count++;
          
                    BufferedWriter out = new BufferedWriter(fstream);
                line = "Case #"+count+": "+passPi;
                out.write(line);
                out.newLine();
                out.close();
        }
        catch(Exception e)
        {
            System.out.println("error is " +e.getMessage());
        }
    }
     
     public static int findProbabilityPi(int NoOfGooglers, int surprisingResults,int pi,ArrayList<Integer>scores)
     {
         int passPi = 0;
         NoOfGooglers = 3;
         for(int sc : scores)
         {
             if( sc % NoOfGooglers == 0)
             {
                  if( (sc/3) == 0 && pi != 0)
                      continue;
                 if( sc/NoOfGooglers >= pi)
                 {    passPi++;
                      continue;
                 }
                 if( surprisingResults>0 )
                 {
                       
                        if( (sc/NoOfGooglers)+1 >= pi)
                        {    passPi++;
                             surprisingResults--;
                             continue;
                        }
                     
                 }
                 
             }
             else if( (sc+1) % NoOfGooglers == 0)
             {
                  if( (sc+1)/NoOfGooglers >= pi)
                  {
                      passPi++;
                      continue;
                  }
             }
             else if( (sc-1) % NoOfGooglers == 0)
             {
                  if( (((sc-1)/NoOfGooglers)+1) >= pi)
                  {
                      passPi++;
                      continue;
                  }
             }
             
             if(surprisingResults > 0)
             {
                    if( (sc+2) % NoOfGooglers == 0)
                    {
                        if( (sc+2)/NoOfGooglers >= pi)
                        {
                            passPi++;
                            surprisingResults--;
                            continue;
                        }
                    }
                    else if( (sc-2) % NoOfGooglers == 0)
                    {
                        if( (((sc-2)/NoOfGooglers)+2) >= pi)
                        {
                            passPi++;
                            surprisingResults--;
                            continue;
                        }
                    }
             }
         }
         return passPi;
     }
     
}
