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;
	}
	
	
}

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Arrays;
import java.util.StringTokenizer;

/**
 * 
 */

/**
 * @author Bageshwar
 *
 */
public class Dance {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		

		
		BufferedReader fr = new BufferedReader(new FileReader(new File(args[0])));
		String str =fr.readLine();
		System.out.println(str);
		int lines = Integer.parseInt(str);
		FileWriter writer = new FileWriter(new File(args[1]));
		StringTokenizer stk ;
		for(int i=0;i<lines;i++){
		
			str = fr.readLine();
			stk = new StringTokenizer(str," ");
			int c = Integer.parseInt((String) stk.nextElement());
			int surprize = Integer.parseInt((String) stk.nextElement());
			int high = Integer.parseInt((String) stk.nextElement());
			int data[] = new int[c];
			int triplets[][] = new int[c][3];
			boolean surprizeFlag=(surprize==0);
			int surprizeCount=0;
			int countHigh=0;
			System.out.print("Case #("+surprize+")"+(i+1));
			writer.write("Case #"+(i+1)+": ");
			System.out.print(" "+high+": ");
			for(int j=0;j<c;j++){
				data[j]=Integer.parseInt((String) stk.nextElement());
				triplets[j]=getTriplets(data[j],surprizeFlag,high);
				if(isSurprize(triplets[j]) && (++surprizeCount)>=surprize)
					surprizeFlag=true;
			
				System.out.print(data[j]+"="+Arrays.toString(triplets[j])+" ");
				if(isHigh(triplets[j],high))
					countHigh++;
			}
			System.out.println(countHigh+"");
			writer.write(countHigh+"\r\n");
		}
		writer.close();
		fr.close();
		
	}
	
	private static boolean isHigh(int[] is,int h) {
		if(is[0]>=h || is[1]>=h || is[2]>=h)
			return true;
		return false;
	}

	static boolean isSurprize(int[] a ){
		if(Math.abs(a[0]-a[1])>1)
			return true;
		
		if(Math.abs(a[0]-a[2])>1)
			return true;
		
		if(Math.abs(a[1]-a[2])>1)
			return true;
		
		return false;
			
	}

	
	private static int[] getTriplets(int x,boolean surprizeFlag,int high){
		
		if(x==0)
		return new int[]{0,0,0};
		//int x=20;
		int a,b,c;
		a=x/3;
		int t=3*a-x;
		if(t%2==0){
			//adjusting for highest
			if( (a>=high || (a-t/2) >=high) ||  
					((a-t/2)+1)<high ||
					surprizeFlag){
				b=(a-t/2);
				c=b;
			}else{
				System.out.print("(!)");
			b=(a-t/2)+1;
			c=b-2;
			}
			//b=b+1;
			//c=c-1;
		}else {
			//remainder is 1 ! 
			b=a;
			c=b-t;
		}
		//System.out.printf("%d %d %d",a,b,c);
		return new int[]{a,b,c};
		
	}
}
