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.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.util.*;


public class B implements Runnable{

	public static void main(String[] args) {
		new Thread(new B()).start();
	}

	private BufferedReader in;
	private PrintWriter out;
	
	public B() {
		try {
			System.setIn(new FileInputStream("C:/Users/Admin/AppData/Local/Temp/b-small.in"));
			System.setOut(new PrintStream(new FileOutputStream("b-small.out")));
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		in = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
	}
	
	@Override
	public void run() {
		// TODO Auto-generated method stub
		System.err.println("hello");
		String Scases = null;
		try {
			Scases = in.readLine();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		int cases = Integer.parseInt(Scases);
		System.err.println(cases + " tests found.");
		for(int testNo = 1; testNo <= cases; testNo++) {
			out.print("Case #" + testNo + ": ");
			
			try {
				String line1 = in.readLine();
				
				String[] strings = line1.split(" ");
				int participants = Integer.parseInt(strings[0]);
				int surprises = Integer.parseInt(strings[1]);
				int neededScore = Integer.parseInt(strings[2]);
				
				System.err.printf("%d participants, %d surprises, %d min. score.\n", participants, surprises, neededScore);
				
				Vector<Integer> scores = new Vector<Integer>();
				for (int i=3; i < strings.length; i++) {
					scores.add(Integer.parseInt(strings[i]) );
				}
				System.err.printf("scores: %s \n", scores.toString());
				
				int possible = 0;
				int possibleWithSurprise = 0;
				int impossible = 0;
				
				for(int score : scores) {
					float f = score / 3.0f;
					float diff = neededScore - f;
					
					if ( (2*(Math.max(neededScore-2,0)) + 1*neededScore) > score) {
						impossible++;
					} else {
						if (diff >= 0.7 && diff < 1.4) {
							possibleWithSurprise++;
						} else if (diff < 0.7) {
							possible++;
						} else {
							impossible++;
						}
					}
					
					System.err.println("score/3: " + f + "nf:" + (neededScore - f) );
					}
				System.err.printf("%d possible %d possibleWithSurprise %d impossible\n\n", possible, possibleWithSurprise, impossible);					
				
				int total = Math.min(possibleWithSurprise, surprises) + possible;
				out.print(total);
				
				
				
			} catch (Exception e) {
				System.err.println(e.getMessage());
			}
			out.print("\n");
		}
		out.close();
	}

}
