import java.io.BufferedReader;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.StringTokenizer;


public class DancingWithTheGooglers {
	public static void main(String[] args) throws IOException {
		BufferedReader f = new BufferedReader (new FileReader("B-small.in"));
		PrintWriter out = new PrintWriter(new FileWriter("B-small.out"));
		
		int t = Integer.parseInt(f.readLine());
		for (int i = 0; i < t; i++){
			int c = 0;
			StringTokenizer st = new StringTokenizer(f.readLine());
			int n = Integer.parseInt(st.nextToken());
			int[] ti = new int[n];
			int s = Integer.parseInt(st.nextToken());
			int p = Integer.parseInt(st.nextToken());
			for (int j = 0; j < n; j ++){
				ti[j] = Integer.parseInt(st.nextToken());
				if (ti[j] % 3 == 0){
					if (ti[j] / 3 >= p)
						c++;
					else if (ti[j] / 3 == (p-1) && s > 0 && ti[j] >= 2){
						s--;
						c++;
					}
				}
				else if (ti[j] % 3 == 1){
					if ((ti[j] / 3) + 1 >= p)
						c++;					
				}
				else{
					if (ti[j] / 3 >= p-1)
						c++;
					else if (ti[j] / 3 == (p-2) && s > 0){
						s--;
						c++;
					}
				}
					
				
			}
			out.println("Case #" + (i+1) + ": " + c);
			
			
		}
		out.close();
		System.exit(0);
		
		
		
	}
}

package qual;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class B {
  static int rec(int[][] memo , List<Integer> tlist , int supprize , int pos , int point){
    int N = tlist.size();
    if(pos == N){
      return 0;
    }
    if(memo[pos][supprize] >= 0){
      return memo[pos][supprize];
    }
    int left = tlist.size() - pos;
    int ti = tlist.get(pos);
    int tave = ti / 3;
    int smax = ti % 3 == 2 ? tave + 2 : tave + 1;
    int nmax = ti % 3 == 0 ? tave     : tave + 1;
    if(supprize == left){
      int ret = rec(memo , tlist , supprize - 1 , pos + 1, point) + (smax >= point ? 1 : 0);
      return ret;
    }else if(supprize == 0){
      int ret = rec(memo , tlist , supprize, pos + 1, point) + (nmax >= point ? 1 : 0);
      return ret;
    }else{
      int ret = rec(memo , tlist , supprize - 1 , pos + 1, point) + (smax >= point ? 1 : 0);
      ret = Math.max(ret, rec(memo , tlist , supprize, pos + 1, point) + (nmax >= point ? 1 : 0));
      return ret;
    }
  }
  
  static int solve(int ts[] , int S , int p){
    List<Integer> tlist = new ArrayList<Integer>();
    int offset = 0;
    for(int t : ts){
      if(t == 0){
        if(p == 0)++offset;
      }else if(t == 1){
        if(p <= 1)++offset;
      }else if(t >= 29){
        ++offset;
      }else{
        tlist.add(t);
      }
    }
    int N = tlist.size();
    int dp[][] = new int[N][S + 1];
    for(int i = 0 ; i < N ; ++i){
      Arrays.fill(dp[i], -1);
    }
    return offset + rec(dp, tlist, S, 0 , p);
  }
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int T = sc.nextInt();
    for(int cn = 1 ; cn <= T ; ++cn){
      int N = sc.nextInt();
      int S = sc.nextInt();
      int p = sc.nextInt();
      int ts[] = new int[N];
      for(int i = 0 ; i < N ; ++i){
        ts[i] = sc.nextInt();
      }
      System.out.printf("Case #%d: %d\n", cn , solve(ts , S , p));
    }
  }
}
