package util.graph;

import java.util.HashSet;
import java.util.PriorityQueue;
import java.util.Set;

public class DynDjikstra {
    public static State FindShortest(Node start, Node target) {
        PriorityQueue<Node> openSet = new PriorityQueue<>();
        Set<Node> closedSet = new HashSet<>();
        openSet.add(start);
        while (!openSet.isEmpty()) {
            Node current = openSet.poll();
            for (Edge edge : current.edges) {
                Node end = edge.target;
                if (closedSet.contains(end)) {
                    continue;
                }
                State newState = edge.travel(current.last);
                //if (end.equals(target)) {
                    //return newState;
                //}
                if (openSet.contains(end)) {
                    if (end.last.compareTo(newState)>0) {
                        end.last = newState;
                    }
                } else {
                    openSet.add(end);
                    end.last = newState;
                }
            }
            closedSet.add(current);
            if (closedSet.contains(target)) {
                return target.last;
            }
        }

        return target.last;
    }
}

import java.io.InputStreamReader;
import java.util.Scanner;

public class Solution {
	public static void main(String argc[]){
		Scanner sc=new Scanner(new InputStreamReader(System.in));
		int t,n,s,p;
		t=sc.nextInt();
		for(int ca=1;ca<=t;ca++){
			n=sc.nextInt();
			s=sc.nextInt();
			p=sc.nextInt();
			int ti;
			int count=0;
			for(int i=0;i<n;i++){
				ti=sc.nextInt();
				if(p<=10){
					int a=ti/3;
					if(ti%3==0){
						if(a>=p)count++;
						else if(s>0&&a+1==p&&a-1>=0){
							s--;
							count++;
						}
					}
					else if(ti%3==1){
						if(a+1>=p)count++;
					}
					else {
						if(a+1>=p)count++;
						else if(a+2==p&&s>0){
							s--;
							count++;
						}
					}

				}
			}
			System.out.println("Case #"+ca+": "+count);
		}

	}
}
