package com.example;

import java.io.IOException;
import java.util.List;

public class ProblemB {
    
    enum Result {
	INSUFFICIENT,
	SUFFICIENT,
	SUFFICIENT_WHEN_SURPRISING
    }

    public static void main(String[] a) throws IOException {

	List<String> lines = FileUtil.getLines("/B-large.in");
	
	int cases = Integer.valueOf(lines.get(0));
	
	for(int c=0; c<cases; c++) {
	    String[] tokens = lines.get(c+1).split(" ");
	    
	    int n = Integer.valueOf(tokens[0]); // N = number of Googlers
	    int s = Integer.valueOf(tokens[1]); // S = number of surprising triplets
	    int p = Integer.valueOf(tokens[2]); // P = __at least__ a score of P
	    
	    int sumSufficient = 0;
	    int sumSufficientSurprising = 0;
	    
	    for(int i=0; i<n; i++) {
		int points = Integer.valueOf(tokens[3+i]);
		
		switch(test(points, p)) {
		case SUFFICIENT:
		    sumSufficient++;
		    break;
		    
		case SUFFICIENT_WHEN_SURPRISING:
		    sumSufficientSurprising++;
		    break;
		}
		
//		uSystem.out.println("points "+ points +" ? "+ p +" => "+ result);
	    }
	    
	    System.out.println("Case #"+ (c+1) +": "+ (sumSufficient + Math.min(s, sumSufficientSurprising)));
	    
//	    System.out.println();
//	    System.out.println("N="+ n +", S="+ s +", P="+ p);
//	    System.out.println();
	}
    }

    private static Result test(int n, int p) {
	int fac = n / 3;
	int rem = n % 3;
	
	if(rem == 0) {
	    
//	    int triplet0[] = { fac, fac, fac };
//	    print(n, triplet0);
	    
	    if(fac >= p) {
		return Result.SUFFICIENT;
	    }
	    
	    if(fac > 0 && fac < 10) {
		
		if(fac+1 >= p) {
		    return Result.SUFFICIENT_WHEN_SURPRISING;
		}
		
//		int triplet1[] = { fac+1, fac, fac-1 }; // surprising 
//		print(n, triplet1);
	    }
	    
	    
	} else if(rem == 1) {
	    
//	    int triplet0[] = { fac+1, fac, fac };
//	    print(n, triplet0);
	    
	    if(fac+1 >= p) {
		return Result.SUFFICIENT;
	    }
	    
//	    if(fac > 0 && fac < 10) {
//		int triplet1[] = { fac+1, fac+1, fac-1 };
//		print(n, triplet1);
//	    }
	    
	} else if(rem == 2) {
	    
//	    int triplet0[] = { fac+1, fac+1, fac };
//	    print(n, triplet0);
	    
	    if(fac+1 >= p) {
		return Result.SUFFICIENT;
	    }
	    
	    if(fac < 9) {
//		int triplet1[] = { fac+2, fac, fac }; // surprising
//		print(n, triplet1);

		if(fac+2 >= p) {
		    return Result.SUFFICIENT_WHEN_SURPRISING;
		}
	    }
	    
	} else {
	    throw new RuntimeException("error");
	}
	
	return Result.INSUFFICIENT;
//	System.out.println();
//	System.out.println(n +" => "+ div3 +" ("+ rem +")");
    }
    
//    private static void print(int n, int[] triplet) {
//	System.out.println("n="+ n +" ("+ (n/3) +","+ (n%3) +") => ["+ triplet[0] +","+ triplet[1] +","+ triplet[2] +"]" + (triplet[0]-triplet[2] > 1 ? " *" : ""));
//    }
    
}

package problem2;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Blarge implements Runnable {

	private final static long UPDATE_INTERVAL_MILLIS = 3000;
	
	private static long startTime;
	private static long currTime;
	private static long endTime;
	private static int run = 0;
	private static int totalNumberOfRuns = 0; 
	
	private String fileName = "B-large.in";
	
	private BufferedReader br;
	private PrintWriter pw;
	
	/**
	 * This method is called, when set-up is complete. 
	 */
	private void solve() {

		totalNumberOfRuns = Integer.parseInt(readLine());
		
		for (run = 0; run < totalNumberOfRuns; run++) {
			
			String[] ins = readLine().split(" ");
			int index = 0;
			
			int numberOfDancers = Integer.parseInt(ins[index++]);
			int surprisingResults = Integer.parseInt(ins[index++]);
			int minResult =  Integer.parseInt(ins[index++]);
			
			int dancersWithMinResult = 0;
			
			for (int i = 0; i < numberOfDancers; i++) {
				int scoreSum = Integer.parseInt(ins[index + i]);
				
				int singleScore = scoreSum / 3;
				int remainder = scoreSum % 3;
				int bestResult = 0;
				
				if (scoreSum > 0) {
					if (remainder == 1) {
						bestResult = singleScore + 1;
					} else if (remainder == 2) {
						bestResult = singleScore + 1;
						if (bestResult + 1 == minResult && surprisingResults > 0) {
							surprisingResults--;
							bestResult++;
						}
					} else if (remainder == 0) {
						bestResult = singleScore;
						if (bestResult + 1 == minResult && surprisingResults > 0) {
							surprisingResults--;
							bestResult++;
						}
						
					}
				}
				if (bestResult >= minResult) dancersWithMinResult++;
			}
			
			write(run+1, String.valueOf(dancersWithMinResult));
		}
	}
	
	// =====================================================================================
	// File Access
	// =====================================================================================
	
	private String readLine() {
		try {
			return br.readLine();
		} catch (IOException e) {
			throw new IllegalStateException();
		}
	}

	private void write(int caseNumber, String result) {
		pw.println("Case #"+caseNumber+": "+result);
	}
	
	private void loadFile(String fileName) {
		File inFile = new File(this.getClass().getResource(fileName).getFile());
		File outFile = new File(inFile.getAbsolutePath().substring(0, (int)(inFile.getAbsolutePath().length()-2L))+"out");
		outFile.delete();
		try {
			outFile.createNewFile();
			br = new BufferedReader(new InputStreamReader(new FileInputStream(inFile)));
			pw = new PrintWriter(new FileOutputStream(outFile));
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	
	// =====================================================================================
	// Initialisation / cleanup
	// =====================================================================================
	
	public static void main(String[] args) throws InterruptedException {
		System.out.println("Running...");
		startTime = System.currentTimeMillis();
		
		Thread thread = new Thread(new Blarge());
		thread.start();
		
		while (thread.isAlive()) {
			Thread.sleep(UPDATE_INTERVAL_MILLIS);
			updateTime();
		}
		
		endTime = System.currentTimeMillis();
		System.out.println("Finished after "+(endTime-startTime)+" ms");
	}
	
	private static void updateTime() {
		currTime = System.currentTimeMillis();
		float timePerRun;
		if (run > 0)
			timePerRun = (currTime-startTime) / run;
		else
			timePerRun = 0;
		float timeLeft = timePerRun * (totalNumberOfRuns - run);
		
		System.out.println("Runs passed: " + run);
		System.out.println("Estimated time left: "+timeLeft+" ms");
		
	}

	@Override
	public void run() {
		loadFile(fileName);
		solve();
		cleanUp();
	}
	
	private void cleanUp() {
		try {
			pw.flush();
			pw.close();
			br.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}