package problem1;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintStream;
import java.util.Arrays;





public class Problem1 {

    public static void main(String[] args) throws FileNotFoundException, IOException{
        try {
             TextIO.readFile("L:\\Coodejam\\Input\\Input.txt");
        }
        catch (IllegalArgumentException e) {
              System.out.println("Can't open file ");
              System.exit(0);
         }
        
        FileOutputStream fout = new FileOutputStream("L:\\Coodejam\\Output\\output.txt");
        PrintStream ps=new PrintStream(fout);
        
        int cases=TextIO.getInt();
        int googlers=0,surprising=0,least=0;
        for(int i=0;i<cases;i++){
            int counter=0;
            googlers=TextIO.getInt();
            surprising=TextIO.getInt();
            least=TextIO.getInt();
            int score[]=new int[googlers];
            for(int j=0;j<googlers;j++){
                score[j]=TextIO.getInt();
                 }
            
            
            
            
            Arrays.sort(score);
            int temp=0;
            int sup[]=new int[surprising];
            
          for(int j=0;j<googlers && surprising>0;j++){
               if(biggestNS(score[j])<least && biggestS(score[j])==least){
                   surprising--;
                   counter++;
                }
               }
           
            for(int j=0;j<googlers;j++){
                if(surprising==0)temp=biggestNS(score[j]);
                    
                else {
                    temp=biggestS(score[j]);
                    surprising--;     
                } 
                   if(temp>=least)counter++;
           
             }
            
             ps.println("Case #"+(i+1)+": "+counter);
        }
    }
    
   static int biggestNS(int x){
       if(x==0)return 0;
       if(x==1)return 1;
       return ((x-1)/3)+1;
   }
   
   static int biggestS(int x){
       if(x==0)return 0;
       if(x==1)return 1;
       return ((x-2)/3)+2;
   }
}
import java.io.*;
import java.security.SecureRandom;
import java.util.*;
import java.math.*;
import java.awt.geom.*;

import static java.lang.Math.*;

public class Main implements Runnable {
	
	static String filename = "B-small-attempt0";
	
	public void solve() throws Exception {
		int t = sc.nextInt();
		for (int Case = 1; Case <= t; Case++) {
			int n = sc.nextInt(), s = sc.nextInt(), p = sc.nextInt();
			ArrayList<Integer>[] points = new ArrayList[3];
			for (int i = 0; i < 3; i++) {
				points[i] = new ArrayList<Integer>();
			}
			for (int i = 0; i < n; i++) {
				int num = sc.nextInt();
				points[num % 3].add(num);
			}
			for (int i = 0; i < 3; i++) {
				Collections.sort(points[i]);
			}
			int ans = 0;
			for (int i = points[0].size() - 1; i >= 0; i--) {
				if (points[0].get(i) / 3 >= p) {
					ans++;
					points[0].remove(i);
				}
			}
			for (int i = points[1].size() - 1; i >= 0; i--) {
				if (points[1].get(i) / 3 + 1 >= p) {
					ans++;
					points[1].remove(i);
				}
			}
			for (int i = points[2].size() - 1; i >= 0; i--) {
				if (points[2].get(i) / 3 + 1 >= p) {
					ans++;
					points[2].remove(i);
				}
			}
			for (int i = points[0].size() - 1; i >= 0 && s > 0; i--) {
				if (points[0].get(i) >= 3 && points[0].get(i) / 3 + 1 >= p) {
					ans++;
					s--;
					points[0].remove(i);
				}
			}
			for (int i = points[2].size() - 1; i >= 0 && s > 0; i--) {
				if (points[2].get(i) / 3 + 2 >= p) {
					ans++;
					s--;
					points[2].remove(i);
				}
			}
			out.printf("Case #%d: %d\n", Case, ans);
		}
	}
	
	BufferedReader in;
	PrintWriter out;
	FastScanner sc;
	
	
	public static void main(String[] args) {
		new Thread(null, new Main(), "", 1 << 25).start();
	}
	
	@Override
	public void run() {
		try {
			init();
			solve();
		} catch (Exception e) {
			throw new RuntimeException(e);
		} finally {
			out.close();
		}
	}
	
	void init() throws Exception {
		in = new BufferedReader(new FileReader(filename + ".in"));
		out = new PrintWriter(new FileWriter(filename + ".out"));
		sc = new FastScanner(in);
	}
}

class FastScanner {
	
	BufferedReader reader;
	StringTokenizer strTok;
	
	public FastScanner(BufferedReader reader) {
		this.reader = reader;
	}
	
	public String nextToken() throws IOException {
		while (strTok == null || !strTok.hasMoreTokens()) {
			strTok = new StringTokenizer(reader.readLine());
		}
		
		return strTok.nextToken();
	}
	
	public int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}
	
	public long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}
	
	public double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}
	
	public BigInteger nextBigInteger() throws IOException {
		return new BigInteger(nextToken());
	}
	
}
