package googlers;

import java.util.Scanner;
import java.util.PriorityQueue;
import java.util.Comparator;
public class Googlers {
	
	public static void main(String[] args) {
		
		int n,s,p,count=0,t;		
		Scanner sin=new Scanner(System.in);
		
		t=Integer.parseInt(sin.nextLine());
		
		
		int result[]=new int[t];
		int j=0;
		
		if(t>=1 && t<=100)
		{
		for (int k = 0; k < t; k++) {
		count=0;	
		
			
        String ip = sin.nextLine();
        
        String[]tokens=ip.split(" ");
		
		
		n=Integer.parseInt(tokens[0]);
		s=Integer.parseInt(tokens[1]);
		p=Integer.parseInt(tokens[2]);
		
		if( (s>=0 && s<=n) && (p>=0 && p<=10) )
		{
		int[] total=new int[n];
		
		
		for (int i = 0; i < n; i++)
        {
            total[i] = Integer.parseInt(tokens[i+3]);
        }
		
		Comparator comparator=new PointComparator();
		PriorityQueue pq=new PriorityQueue<Point>(1, comparator);
		
		for (int i = 0; i < n; i++)
		{
			
			int x=total[i]/3;
			int r=total[i]%3;
			if(x>=p)
				count++;
			else if(x<(p-2))
				continue;
			else
			{
				//System.out.println("enter "+x+" "+(p-2));
				if(p-x==1)
				{
					Point temp=new Point();
					temp.q=x;
					temp.r=r;
					pq.add(temp);
				}
				else  // p-x=2
				{
					if(r==0)
						continue;
					else
					{
						Point temp=new Point();
						temp.q=x;
						temp.r=r;
						pq.add(temp);
					}				
					
				}
					
			}
			//System.out.println("hi "+pq.size());
			
		}
		
		
		
		while(pq.size()!=0)
		{
			Point temp=(Point)pq.remove();
			if(p-temp.q==1 && temp.q!=0)
			{
				if(temp.r>=1)
					count++;
				else
				{
					if(s!=0)
					{
						s--;
						count++;
					}
				}
			}
			else if(p-temp.q==2)
			{
				if(s!=0 && (temp.q+temp.r)>=p)
				{
					s--;
					count++;
				}
			}
			
				
		}
		
		//System.out.println(p);
		
		result[j++]=count;
		
		}
		}
		
		for (int i = 0; i < t; i++) 
		{
			System.out.println("Case #"+(i+1)+": "+result[i]);
		}
		}
		
	}
        
        
		
		/*Point x=new Point();
		x.q=8;
		Point y=new Point();
		y.q=6;
		Point z=new Point();
		z.q=7;
		
		pq.add(x);
		pq.add(y);
		pq.add(z);
		*/
		
		
		
		
	

}

class PointComparator implements Comparator<Point>
{
    @Override
    public int compare(Point x, Point y)
    {
        // Assume neither string is null. Real code should
        // probably be more robust
        if (x.q < y.q)
        {
            return 1;
        }
        if (x.q  > y.q)
        {
            return -1;
        }
        return 0;
    }
}



class Point
{
	int q,r;

	public int getQ() {
		return q;
	}

	public void setQ(int q) {
		this.q = q;
	}

	public int getR() {
		return r;
	}

	public void setR(int r) {
		this.r = r;
	}
	
	
}

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

import java.io.*;

/**
 *
 * @author GreenTie
 */
public class PracticeJam {

//    public int[] compute(int[][] input){
//        int[] result=new int[input.length];
//        for(int i=0;i<input.length;i++)
//            result[i]=compute(input[0],input[1]);
//        return result;
//    }
    public static int compute(int n, int k) {
        if ((k & 0x01) == 0) {
            return 0;
        } else {
            int x = (1 << n);
            return (k + 1) % x == 0 ? 1 : 0;
        }
    }
    public static final String[] Result = {"OFF", "ON"};
    public static final char[] DicB = {'Y', 'H', 'E', 'S', 'O', 'C', 'V', 'X', 'D', 'U', 'I', 'G', 'L', 'B', 'K', 'R', 'Z', 'T', 'N', 'W', 'J', 'P', 'F', 'M', 'A', 'Q'};
    public static final char[] DicA = {'y', 'h', 'e', 's', 'o', 'c', 'v', 'x', 'd', 'u', 'i', 'g', 'l', 'b', 'k', 'r', 'z', 't', 'n', 'w', 'j', 'p', 'f', 'm', 'a', 'q'};
    public static final int[] Normal = {0, 1, 1, 1,
        2, 2, 2,
        3, 3, 3,
        4, 4, 4,
        5, 5, 5,
        6, 6, 6,
        7, 7, 7,
        8, 8, 8,
        9, 9, 9,
        10, 10, 10};
    public static final int[] Surprising = {0,
        0, 2, 2,
        2, 3, 3,
        3, 4, 4,
        4, 5, 5,
        5, 6, 6,
        6, 7, 7,
        7, 8, 8,
        8, 9, 9,
        9, 10, 10,
        10, 0, 0
    };

    public static String problemA(String G) {
        StringBuilder sb = new StringBuilder(G.length());
        for (int i = 0; i < G.length(); i++) {
            char x = G.charAt(i);
            if (x >= 'A' && x <= 'Z') {
                sb.append(DicB[x - 'A']);
            } else if (x >= 'a' && x <= 'z') {
                sb.append(DicA[x - 'a']);
            } else {
                sb.append(x);
            }
        }
        return sb.toString();
    }
    
    public static int problemB(String G){
        int result=0;
        String[] temp=G.split(" ");
        int N=Integer.parseInt(temp[0]);
        int S=Integer.parseInt(temp[1]);
        int p=Integer.parseInt(temp[2]);
        int[] scr=new int[N];
        int count=N;
        int suprise=S;
        for(int i=0;i<N;i++){
            scr[i]=Integer.parseInt(temp[i+3]);
            if(scr[i]>=29){result++;count--;}
            else if(scr[i]==1){count--;if(p<=1)result++;}
            else if(scr[i]==0){count--;if(p==0)result++;}
            else if(Normal[scr[i]]>=p){
                result++;count--;
            }
            else{
                if(Surprising[scr[i]]>=p&&suprise>0){
                    result++;
                    count--;
                    suprise--;
                }
            }
        }
        
        return result;
    }
    

    /**
     * @param args the command line arguments
     */
    public static void mainA(String[] args) {
        String[] x = {"ejp mysljylc kd kxveddknmc re jsicpdrysi", "rbcpc ypc rtcsra dkh wyfrepkym veddknkmkrkcd", "de kr kd eoya kw aej tysr re ujdr lkgc jv"};
        for (String G : x) {
            System.out.println(problemA(G));
        }
    }

    public static void main(String[] args) throws FileNotFoundException, IOException {
        BufferedReader br = new BufferedReader(new FileReader(new File("B-small-attempt0.in")));
        int x = Integer.parseInt(br.readLine());
        StringBuilder sb = new StringBuilder();
        for (int i = 1; i <= x; i++) {
            //String[] temp=br.readLine().trim().split(" ");
            sb.append("Case #").append(i).append(": ").append(problemB(br.readLine()));
            sb.append('\n');
            //sb.append("Case #").append(i).append(": ").append(Result[compute(Integer.parseInt(temp[0]),Integer.parseInt(temp[1]))]).append('\n');
            //System.out.printf("Case #%d: %s\n",i,Result[compute(Integer.parseInt(temp[0]),Integer.parseInt(temp[1]))]);   
        }
        System.setOut(new PrintStream(new File("B-small-attempt0.out")));
        System.out.print(sb.toString());
        br.close();

    }
}
