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.*;
import java.util.*;

public class DancingGooglers {
	
	static class InputReader {
		BufferedReader bin;
		StringTokenizer tokenizer;
		
		public InputReader(InputStream in) {
			bin = new BufferedReader(new InputStreamReader(in));
			tokenizer = null;
		}
		
		public InputReader(String fname) {
			try {
				bin = new BufferedReader(new FileReader(fname));
				tokenizer = null;
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		
		public String next() {
			
			while( tokenizer == null || !tokenizer.hasMoreTokens())  {
				try {
					tokenizer = new StringTokenizer(bin.readLine());
				} catch(IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}
		
		public String readLine() {
			try {
				return bin.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		
		public int nextInt() {
			return Integer.parseInt(next());
		}
		
		public long nextLong() {
			return Long.parseLong(next());
		}
		
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		
		public float nextFloat() {
			return Float.parseFloat(next());
		}
		
		public void close() {
			try {
				bin.close();
				tokenizer = null;
			} catch ( IOException e) {
				throw new RuntimeException(e);
			}
		}
	}
	
	
	
	
	public static void main(String[] args) throws IOException {
		//InputReader in = new InputReader(System.in);
		InputReader in = new InputReader("B-small-attempt1.in");
		PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("B-small-attempt1.out")));
		//PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
		
		Solver solver = new Solver(in,out);
		solver.solve();
		
		out.close();
		in.close();
	}
	
	private static class Solver {
		InputReader in;
		PrintWriter out;
		HashMap<Integer,triplet> surprising;
		HashMap<Integer,triplet> notsurprising;
		List<Integer> surp,nonsurp,both,potnsurp;
		
		private class triplet {
			int a,b,c;
			
			triplet(int a, int b, int c) {
				this.a = a;
				this.b = b;
				this.c = c;
			}
			
			public boolean surpising() {
				if(Math.abs(a - b) ==2 || Math.abs(a - c) == 2 || Math.abs(b - c) == 2)
					return true;
				return false;
			}
			
			public boolean best(int p) {
				if( a >= p || b >= p || c >= p)
					return true;
				return false;
			}
			
		}
		
		public Solver(InputReader in, PrintWriter out) {
			this.in = in;
			this.out = out;
			surprising = null;
			notsurprising = null;
			surp = null;
			nonsurp = null;
			both = null;
			potnsurp = null;
		}
		
		public void preprocess() {
			if(surprising == null || notsurprising == null) {
				surprising = new HashMap<Integer,triplet>();
				notsurprising = new HashMap<Integer,triplet>();
				surp = new ArrayList<Integer>();
				nonsurp = new ArrayList<Integer>();
				both = new ArrayList<Integer>();
				potnsurp = new ArrayList<Integer>();
				generateTriplets();
			}
		}
		
		public void solve() {
			preprocess();
			int numTc = in.nextInt();
			int numGoog,numSurp,bestScore,soln = 0,score,numberOfSurp;
			triplet temp;
			
			for ( int i = 0; i < numTc; i++ ) {
				numGoog = in.nextInt();
				numSurp = in.nextInt();
				bestScore = in.nextInt();
				surp.clear();
				nonsurp.clear();
				both.clear();
				numberOfSurp = 0;
				for ( int j = 0; j < numGoog; j++ ) {
					score = in.nextInt();
					if(surprising.containsKey(score) && notsurprising.containsKey(score)) {
						temp = surprising.get(score);
						if(temp.best(bestScore)) {
							temp = notsurprising.get(score);
							if(temp.best(bestScore))
								both.add(j);
							else 
								surp.add(j);
						}
						else {
							temp = notsurprising.get(score);
							if(temp.best(bestScore))
								nonsurp.add(j);
							else
								numberOfSurp++;
						}
					}
					else {
						if(notsurprising.containsKey(score)) {
							temp = notsurprising.get(score);
							if(temp.best(bestScore))
								nonsurp.add(j);
						}
					}
				}
				if(numSurp <= numberOfSurp + surp.size() + both.size())
					soln = countMax(numSurp,numberOfSurp);
				else
					soln = 0;
				out.println("Case #"+(i+1)+": "+soln);
			}
		}
		
		public int countMax(int numSurp, int numberOfSurp) {
			int count = both.size() + nonsurp.size();
			
			if(numSurp < surp.size())
				return count + numSurp;
			
			return count + surp.size();
		}
		
		public void generateTriplets() {
			int sum = 0;
			for ( int i = 0; i < 11; i++ ) {
				for ( int j = 0; j < 11; j++ ) {
					if(Math.abs(j - i) > 2)
						continue;
					for ( int k = 0; k < 11; k++ ) {
						if(Math.abs(k-j) > 2 || Math.abs(k-i) > 2)
							continue;
						sum = i+j+k;
						triplet temp = new triplet(i,j,k);
						if(temp.surpising())
							surprising.put(sum, temp);
						else
							notsurprising.put(sum, temp);
					}
				}	
			}
		}
		
		public int bruteforce() {
			
			return 0;
		}
		
	}
}

