package dancinggooglers;

import java.io.File;
import java.util.Scanner;

public class DanceScoreCalculator {


    public static void main(String[] args) {
        if(args.length <= 0 || args[0] == null) {
            System.out.println("You must enter a file to read");
            System.out.println("Usage: blah <filename>");
            System.exit(0);
        }

        File argFile = new File(args[0]);
        try {
            Scanner googleSpeakScanner = new Scanner(argFile);
            String firstLine = googleSpeakScanner.nextLine();
            Integer linesToScan = new Integer(firstLine);
            for(int i = 1; i <= linesToScan; i++) {
                String googleDancerLine = googleSpeakScanner.nextLine();
                DanceScoreCase danceCase = new DanceScoreCase(googleDancerLine);
                System.out.println(String.format("Case #%d: %d", i, danceCase.maxDancersThatCouldPass()));
            }
        }
        catch (Exception e) {
            e.printStackTrace();
        }
    }
}


import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Scanner;

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

/**
 *
 * @author Akash Agrawal
 */
public class DWG {
    
    public static void main(String [] args) throws FileNotFoundException, IOException
    {
        Scanner scan= new Scanner(new File("inp.txt"));
        
        int n=scan.nextInt();
        //System.out.println(n);
        int cas=1;
        while(n--!=0)
        {
            int t=scan.nextInt();
            int s=scan.nextInt();
            int p=3*scan.nextInt();
            
            int count =0;
            for(int i=0;i<t;i++)
            {
                int temp = scan.nextInt();
                //System.out.println(temp);
                if(temp == 0 && p==0 )count++;
                else if(temp == 0 )continue;
                else if(temp==1 && p==1) count++; 
                if(temp>=p-2)count++;
                else if(temp>=p-4 && s>0 )
                {count++;s--;}
                
            }
            
            System.out.println("Case #"+cas+++": "+count);
            
        }
        }
    
}
