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

/**
 * 
 */
package hu.herba.codejam.cj2012.qualification;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Arrays;

import hu.herba.codejam.AbstractCodeJamBase;

/**
 * Dancing with the Googlers
 * 
 * @author csorbazoli
 */
public class ProblemB extends AbstractCodeJamBase {

    public static void main(String[] args) {
	new ProblemB(args);
    }

    int T; // number of test case

    public ProblemB(String[] args) {
	super(args, AbstractCodeJamBase.READER_TYPE);
    }

    /*
     * (non-Javadoc)
     * 
     * @see hu.herba.codejam.AbstractCodeJamBase#process(java.io.BufferedReader,
     * java.io.PrintWriter)
     */
    @Override
    protected void process(BufferedReader reader, PrintWriter pw) throws IOException, IllegalArgumentException {
	// The first line of the input gives the number of test cases, T. T test
	// cases follow, one per line.
	this.T = this.readInt(reader, "Number of cases");
	int[] items;
	int result = 0;
	int N, S, p;
	int surp, smallest, cur, diff;
	for (int i = 1; i <= this.T; i++) {
	    items = this.readIntArray(reader, "N, S, p and N integers");
	    // The first integer will be N, the number of Googlers,
	    // and the second integer will be S, the number of surprising
	    // triplets of scores.
	    // The third integer will be p, as described above.
	    // Next will be N integers ti: the total points of the Googlers.
	    if ((items.length > 0) && (items.length == 3 + items[0])) {
		// * TEST */System.out.println("Case #" + i + ": input = " +
		// Arrays.toString(items));
		N = items[0];
		S = items[1];
		p = items[2];
		// For each test case, output one line containing "Case #x: y",
		// where x is the case number (starting from 1) and y is the
		// maximum number of Googlers who could have had a best result
		// of greater than or equal to p.
		surp = result = 0;
		for (int j = 0; j < N; j++) {
		    cur = items[3 + j];
		    if (cur >= p) {
			// smallest result
			smallest = (cur - p) / 2;
			diff = p - smallest;
			if (diff <= 2) {
			    if (diff == 2) { // only when suprising
				surp++;
				// * TEST */System.out.println("	" + cur +
				// " -> SUPP");
			    } else { // even if not surprising
				// * TEST */System.out.println("	" + cur +
				// " -> MAX");
				result++;
			    }
			} // else not possible
		    }
		}
		// at most S googlers may have p points amoung surp
		// * TEST */System.out.println("	result = " + result + " + " +
		// Math.min(surp, S));
		result += Math.min(surp, S);
		pw.println("Case #" + i + ": " + result);
	    } else {
		System.out.println("Test case " + i + " INVALID: input line should contain N, S, p and N integers" + Arrays.toString(items));
	    }
	}
    }
}
