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.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;

/**
 * 
 * @author ysan
 *
 */

public class Problem_B_small {
	

	public static void main(String[] args) throws NumberFormatException,
			IOException {

		BufferedReader in = new BufferedReader(new FileReader("B-large.in"));
		BufferedWriter out = new BufferedWriter(new FileWriter("B-large-output.txt"));
		
		int cases = Integer.parseInt(in.readLine());
		
		 for (int i = 1; i <= cases; i++) {
			 String text = in.readLine().trim();
			 
			 String[] val = text.split(" ");
			 
			 int count = 0;
			 int n = Integer.parseInt(val[0]);
			 int s = Integer.parseInt(val[1]);
			 int p = Integer.parseInt(val[2]);
			 int j;
			 
			
			 
			 for(int h=3; h<val.length;h++)
			 {
				 int target = Integer.parseInt(val[h]);

				 int ro = target / 3;
				 int l =target % 3;
				 int r[] = new int[3];
					 r[0] = ro;
					 r[1] = ro;
					 r[2] = ro;
					 
					 while(l>0)
					 {
						 if(l>0)
							 {r[0] = r[0] + 1;l--;}
						 if(l>0)
							{r[1] = r[1] + 1;l--;}
						 if(l>0)
							{r[2] = r[2] + 1;l--;}
					 }

				 boolean flag = false;

				 for(int c =0; c<3; c++)
					if(r[c] >= p){count++;flag=true;break;}
				 
				 if(!flag && s > 0)
				 {
					 int t = (target - p);
					 ro =  t/2;
					 l = t%2;
					 int r2[] = new int[3];
					 if(target > p){

						 r2[0] = p;
						 r2[1] = ro;
						 r2[2] = ro;
						 while(l>0)
						 {
							 if(l>0)
								{r2[1] = r2[1] + 1;l--;}
							 if(l>0)
								{r2[2] = r2[2] + 1;l--;}
						 }
						 if(r2[0] - r2[1]<=2 && r2[0] - r2[2]<=2)
						 {
							 r[0] = r2[0];
							 r[1] = r2[1];
							 r[2] = r2[2];
							 s--;
						 }
					 }
					 
					 for(int c =0; c<3; c++)
							if(r[c] >= p){count++;break;}
				 }
			 }
			 
			 
			 
			 out.write("Case #"+ i +": " + count);
			 out.newLine(); 
			 
		 }
		

		
		
		
		
		
		
		
		 
		
		in.close();
		out.close();
		
		

	}
	
	static void makeCombinations(int n, int p)
    {
        int sum,x,y,z;
        
        for(x=p ; x>=0 ; x--)
        {
        	 for(y=x ; y>=0 ; y--)
             {
        		 sum =x+y;
        		 if(sum==n)
        		 {
        			 continue;
        		 }
        		 else
        		 {
        			 for(z=p ; z>=0 ;  z--)
                     {
        				 sum=sum+z;
        				 if(sum<n)
                             continue;
                         else
                             break;
                     }
        		 }
             }
        }
        
        
        for(x=0 ; x<=10 ; x++)
        {
            for(y=x ; y<=10 ; y++)
            {
                sum =x+y;
                if(sum==n)
                    System.out.println(x + "  +  " + y);
                for(z=0 ; z<=10 ;  z++)
                {
                    sum=sum+z;
                    if(sum<n)
                        continue;
                    else
                        break;
                }//for ends
                 if(sum==n)
                {
                   System.out.print(x + "  +  " + y);
                   for(p=0 ; p<=z ; p++)
                           System.out.print("  +  " + p);
                   System.out.println();
 }//if ends
            }//for ends
        }//for ends
    }//method ends
		
}
