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.*;
import java.util.*;

public class Q2
{
	private static int max (int a, int b, int c)
	{
		return Math.max (a, Math.max (b, c));
	}
	
	public static void main (String[] args) throws IOException
	{
		BufferedReader reader = new BufferedReader (new FileReader ("input-q2.txt"));
		PrintWriter writer = new PrintWriter ("output-q2.txt");
		String line = reader.readLine();
		int nb = Integer.parseInt (line);
		for (int i = 0; i < nb; i++)
		{
			line = reader.readLine();
			String[] tokens = line.split (" ");
			int[] googlers = new int[Integer.parseInt (tokens[0])];
			int s = Integer.parseInt (tokens[1]);
			int p = Integer.parseInt (tokens[2]);
			for (int j = 0; j < googlers.length; j++)
			{
				googlers[j] = Integer.parseInt (tokens[3 + j]);
			}
			
			System.out.printf ("\ns : %d,  p : %d, googlers : %s\n", s, p, Arrays.toString (googlers));
			
			// For each googler
			int counter = 0;
			for (int j = 0; j < googlers.length; j++)
			{
				System.out.print ("Googler " + googlers[j] + " :");
				int a = 0, b = 0, c = 0;
				
				if ((googlers[j] - 2) % 3 == 0)
				{
					a = b = (googlers[j] - 2) / 3;
					c = (googlers[j] - 2) / 3 + 2;
					
					if (max (a, b + 1, c - 1) >= p || c <= 1 || max (a, b, c) < p)
					{
						System.out.printf ("  (%d %d %d)\n", a, b + 1, c - 1);
						if (max (a, b + 1, c - 1) >= p)
						{
							counter++;
						}
						continue;
					}
					else if (s > 0)
					{
						s--;
						if (max (a, b, c) >= p)
						{
							counter++;
						}
						System.out.printf ("  (%d %d %d) *\n", a, b, c);
						continue;
					}
					else
					{
						System.out.println ("ERROR");
					}
				}
				
				if ((googlers[j] - 1) % 3 == 0)
				{
					a = b = (googlers[j] - 1) / 3;
					c = (googlers[j] - 1) / 3 + 1;
					
					if (max (a, b, c) >= p)
					{
						counter++;
					}
					System.out.printf ("  (%d %d %d)\n", a, b, c);
					continue;
				}
				
				if (googlers[j] % 3 == 0)
				{
					a = b = c = googlers[j] / 3;
					
					if (max (a, b, c) >= p || b <= 1 || max (a, b - 1, c + 1) < p || s == 0)
					{
						System.out.printf ("  (%d %d %d)\n", a, b, c);
						if (max (a, b, c) >= p)
						{
							counter++;
						}
						continue;
					}
					else if (s > 0)
					{
						s--;
						if (max (a, b - 1, c + 1) >= p)
						{
							counter++;
						}
						System.out.printf ("  (%d %d %d) *\n", a, b - 1, c + 1);
						continue;
					}
					else
					{
						System.out.println ("ERROR");
					}
				}
			}
			System.out.println ("Counter : " + counter);
			writer.println ("Case #" + (i + 1) + ": " + counter);
		}
		writer.close();
		reader.close();
	}
}