package com.menzus.gcj._2012.qualification.b;

import com.menzus.gcj.common.InputBlockParser;
import com.menzus.gcj.common.OutputProducer;
import com.menzus.gcj.common.impl.AbstractProcessorFactory;

public class BProcessorFactory extends AbstractProcessorFactory<BInput, BOutputEntry> {
    public BProcessorFactory(String inputFileName) {
	super(inputFileName);
    }

    @Override
    protected InputBlockParser<BInput> createInputBlockParser() {
	return new BInputBlockParser();
    }

    @Override
    protected OutputProducer<BInput, BOutputEntry> createOutputProducer() {
	return new BOutputProducer();
    }
}

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
import java.io.*;
import java.util.*;
/**
 *
 * @author Maleen
 */
public class B {
     public static void main(String[] args) throws FileNotFoundException, IOException {
        Scanner sc = new Scanner(new File("in/B.txt"));
        PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("Bout.txt")));
        
        int[] SMax = new int[31];
        int[] NMax = new int[31];
        SMax[0] = 0; NMax[0] = 0;
        for (int i=1;i<=30;i++){
            SMax[i] = Math.min((i+1)/3 +1,10);
            NMax[i] = Math.min((i-1)/3 +1,10);
            
            System.out.println(i+ " "+NMax[i] +" "+ SMax[i]);
        }
        int T = sc.nextInt();
        for (int t=0;t<T;t++){
            int N = sc.nextInt();
            int S = sc.nextInt();
            int P = sc.nextInt();
            int clear = 0;
            int margin = 0;
            for (int i=0;i<N;i++){
                int n = sc.nextInt();
                if (NMax[n] >=P) clear ++;
                else if (SMax[n] >=P) margin++;
            }
            System.out.println("S "+S +" clear "+ clear +" margin "+margin);
            out.println("Case #"+(t+1) + ": "+ (clear + Math.min(margin, S)));
        }
        out.close();
     }
}
