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.File;
import java.io.FileNotFoundException;
import java.util.Arrays;
import java.util.Scanner;

public class BSmall {

	static GoogleanScore[]	allScores	= new GoogleanScore[31];
	static int				T, S, N, p, sums[];
	// static GoogleanScore[] scores;

	static Scanner			scanf;

	public static void main(String[] args) throws FileNotFoundException {
		for (int i = 0; i < 31; i++) {
			allScores[i] = new GoogleanScore(i);
		}

		scanf = new Scanner(new File("BSmall_in.txt"));

		T = scanf.nextInt();

		for (int t = 1; t <= T; t++) {
			int result = -1;
			takeInputForACase();
			switch (S) {
				case 0:
					result = solveForSIsZero();
					break;
				case 1:
					result = solveForSIsOne();
					break;
				case 2:
					result = solveForSIsTwo();
					break;
				case 3:
					result = solveForSIsThree();
					break;
			}

			System.out.println("Case #" + t + ": " + result);
		}
	}

	static void takeInputForACase() {
		N = scanf.nextInt();
		S = scanf.nextInt();
		p = scanf.nextInt();

		sums = new int[N];
		for (int n = 0; n < N; n++) {
			sums[n] = scanf.nextInt();
		}
	}

	static int solveForSIsZero() {
		int result = 0;
		for (int sum : sums) {
			if (allScores[sum].nonSurprising.bestIsAtLeast(p)) {
				result ++;
			}
		}

		return result;
	}

	static int solveForSIsOne() {
		int result = -1;
		for (int sIndex = 0; sIndex < sums.length; sIndex++) {
			int current = 0;
			int sSum = sums[sIndex];

			if (sSum >= 2) {
				if (allScores[sSum].surprising.bestIsAtLeast(p)) {
					current++;
				}
			}

			for (int nsIndex = 0; nsIndex < sums.length; nsIndex++) {
				if (nsIndex == sIndex) {
					continue;
				}
				int nsSum = sums[nsIndex];
				if (allScores[nsSum].nonSurprising.bestIsAtLeast(p)) {
					current++;
				}
			}

			if (current > result) {
				result = current;
			}
		}

		return result;
	}

	static int solveForSIsTwo() {
		int result = -1;

		for (int nsIndex = 0; nsIndex < sums.length; nsIndex++) {
			int current = 0;
			int nsSum = sums[nsIndex];
			if (allScores[nsSum].nonSurprising.bestIsAtLeast(p)) {
				current++;
			}

			for (int sIndex = 0; sIndex < sums.length; sIndex++) {
				if (sIndex == nsIndex) {
					continue;
				}

				int sSum = sums[sIndex];
				if (sSum >= 2) {
					if (allScores[sSum].surprising.bestIsAtLeast(p)) {
						current++;
					}
				}
			}

			if (current > result) {
				result = current;
			}
		}

		return result;
	}

	static int solveForSIsThree() {
		int result = 0;
		for (int sum : sums) {
			if (allScores[sum].surprising.bestIsAtLeast(p)) {
				result += 1;
			}
		}

		return result;
	}

	static class GoogleanScore {
		Triplet	surprising, nonSurprising;

		public GoogleanScore(int score) {
			nonSurprising = new NoSurpriseTriplet(score);
			surprising = new SurprisingTriplet(score);
		}
	}

	static abstract class Triplet {
		int	values[]	= new int[3];

		public Triplet(int sum) {
			generateValues(sum);
		}

		@Override
		public String toString() {
			return Arrays.toString(values);
		}

		boolean bestIsAtLeast(	int p) {
			return values[2] >= p;
		}

		protected abstract void generateValues(	int sum);
	}

	static class NoSurpriseTriplet extends Triplet {

		public NoSurpriseTriplet(int sum) {
			super(sum);
		}

		@Override
		protected void generateValues(	int sum) {
			values[0] = sum / 3;
			sum -= values[0];

			values[1] = sum >> 1;
			values[2] = sum - values[1];
		}
	}

	static class SurprisingTriplet extends Triplet {
		public SurprisingTriplet(int sum) {
			super(sum);
		}

		@Override
		protected void generateValues(	int sum) {
			values[2] = ((sum - 2) / 3) + 2;
			values[0] = values[2] - 2;
			values[1] = sum - (values[0] + values[2]);
		}
	}
}
