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

public class Dancing {

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(new File("B-small-attempt0.in"));
		FileWriter fstream = new FileWriter("Bout.txt");
		BufferedWriter outp = new BufferedWriter(fstream);
		int cases = sc.nextInt();
		for (int r = 0; r < cases; r++) {
			int total = 0;
			int totalS = 0;
			int N = sc.nextInt();
			int S = sc.nextInt();
			int p = sc.nextInt();
			int[] NN = new int[N];
//			System.out.println("Surprising: =" + S);
			for (int rr = 0; rr < N; rr++) {
				NN[rr] = sc.nextInt();
				int a = NN[rr] / 3;
				int b = (NN[rr] - a) / 2;
				int c = NN[rr] - a - b;
				// find surprising score
				// int lowest=a<b?a:b;
				// lowest=lowest<c?lowest:c;
				// int highest=b>a?b:a;
				// highest=highest>c?highest:c;

				// a- b+
				int max = max(a, b, c);
				int maxS = max;

				int a1 = a - 1;
				int b1 = b + 1;
				int c1 = c;
				if (maxDiff(a1,b1,c1)<3&&max(a1, b1, c1) > maxS)
					maxS = max(a1, b1, c1);

				// a- c+
				a1 = a - 1;
				b1 = b;
				c1 = c + 1;
				if (maxDiff(a1,b1,c1)<3&&max(a1, b1, c1) > maxS)
					maxS = max(a1, b1, c1);

				// a+ b-
				a1 = a + 1;
				b1 = b - 1;
				c1 = c;
				if (maxDiff(a1,b1,c1)<3&&max(a1, b1, c1) > maxS)
					maxS = max(a1, b1, c1);

				// a+ c-
				a1 = a + 1;
				b1 = b;
				c1 = c - 1;
				if (maxDiff(a1,b1,c1)<3&&max(a1, b1, c1) > maxS)
					maxS = max(a1, b1, c1);

				// b- c+
				a1 = a;
				b1 = b - 1;
				c1 = c + 1;
				if (maxDiff(a1,b1,c1)<3&&max(a1, b1, c1) > maxS)
					maxS = max(a1, b1, c1);

				// b+ c-
				a1 = a;
				b1 = b + 1;
				c1 = c - 1;
				if (maxDiff(a1,b1,c1)<3&&max(a1, b1, c1) > maxS)
					maxS = max(a1, b1, c1);

				if (max >= p)
					total++;
				if (maxS >= p)
					totalS++;
//				System.out.println(a+" "+b+" "+c+" "+max+" "+maxS);
			}
//			System.out.println(total + " " + totalS);
			int fin=total;
			if (total+S>totalS)fin=totalS;
			else fin=total+S;
            
			System.out.println("Case #" + (r + 1) + ": " + fin);
			outp.write("Case #" + (r + 1) + ": " + fin+"\n");
		}
		outp.flush();
		fstream.close();
	}

	public static int maxDiff(int a, int b, int c) {
		if (a<0||b<0||c<0||a>10||b>10||c>10)return 100;
		double diff1 = Math.abs(a - b);
		double diff2 = Math.abs(a - c);
		double diff3 = Math.abs(b - c);
		return (int) Math.max(Math.max(diff1, diff2), diff3);
	}

	public static int max(int a, int b, int c) {
		return (a > b ? a : b) > c ? (a > b ? a : b) : c;
	}

}
