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 ? " *" : ""));
//    }
    
}

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Scanner;


public class B {
	public static void main(String[] args) {
		CaseB[] cases = read("B-large.in");
		/*
		// test reading
		for (CaseB c : cases) {
			print(c.getInfo());
		}*/
		CaseB c;
		for (int x = 0; x < cases.length; x++) {
			c = cases[x];
			// for each case
			print("Processing case " + x);
			for (int i = 0; i < c.t.length; i++) {
				// for each googler
				int avgBase = c.t[i] / 3;
				int addPoint = c.t[i] % 3;
				int bestResult = avgBase;
				
				// assume no surprising first, if addpoint > 0, best result is at least avgBase + 1
				if (addPoint > 0) {
					bestResult += 1;
				}
				if (bestResult >= c.p) {
					// already larger than p, no surprising needed 
					c.increment();
				} else {
					// use surprising point if possible, 3 conditions
					// 1. still has surprising point to use
					// 2. addPoint is 0 or 2 (surprising can make a difference)
					// 3. total point >= 2 (can't make point 2 apart if the total point is < 2) 
					if (c.hasS() && addPoint != 1 && c.t[i] >= 2) {
						// when addPoint is 0 or 2, best result can be incremented by 1 if is surprising triplet
						if (bestResult + 1 >= c.p) {
							c.useS();
							c.increment();
						}
					}
				}
			}
		}
		
		// write result
		writeFile(cases, "B-large.out");
		print("Complete!");
	}
	
	public static void printf(String format, Object... args) {
		System.out.printf(format, args);
	}
	
	public static void print(Object o) {
		System.out.println(o);
	}
	
	public static void writeFile(CaseB[] result, String out) {
		PrintWriter writer = null;
		try {
			writer = new PrintWriter(out);
			for (int i = 0; i < result.length; i++) {
				writer.printf("Case #%d: %s\n", i+1, result[i]);
			}
			writer.flush();
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} finally {
			if (writer != null) {
				writer.close();
			}
		}
	}
	
	public static CaseB[] read(String file) {
		BufferedReader reader = null;
		CaseB[] cases = null;
		try {
			reader = new BufferedReader(new FileReader(file));
			
			// get test case count
			int caseCount = Integer.parseInt(reader.readLine());
			cases = new CaseB[caseCount];
			for (int i = 0; i < cases.length; i++) {
				Scanner scan = new Scanner(reader.readLine());
				int n = scan.nextInt();
				int s = scan.nextInt();
				int p = scan.nextInt();
				int[] t = new int[n];
				for (int x = 0; x < n; x++) {
					t[x] = scan.nextInt();
				}
				
				cases[i] = new CaseB(s, p, t);
				scan.close();
			}
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} finally {
			if (reader != null) {
				try {
					reader.close();
				} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
		}
		return cases;
	}
}

class CaseB {
	//private int n;	// number of Googler
	private int s;	// number of surprising triplets
	int p;	// expected best result
	int[] t; // total score of each Googler
	
	private int result;
	
	public CaseB(int s, int p, int[] t) {
		this.s = s;
		this.p = p;
		this.t = t;
		this.result = 0;
	}

	public void increment() {
		result++;
	}
	
	public boolean hasS() {
		return s > 0;
	}
	
	public void useS() {
		s--;
	}
	
	public int getResult() {
		return result;
	}

	public void setResult(int result) {
		this.result = result;
	}
	
	@Override
	public String toString() {
		return "" + result;
	}
	
	public String getInfo() {
		String out = t.length + " " + s + " " + p;
		for (int i = 0; i < t.length; i++) {
			out += " " + t[i];
		}
		return out;
	}
}
