import java.io.BufferedReader;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;

public class CodeJam {

//	public static final String INPUT_FILE_PATH = "D://CodeJamInput.txt";
	public static final String INPUT_FILE_PATH = "D://B-large.in";
	public static final String OUTPUT_FILE_PATH = "D://CodeJamOutput.txt";

	public static List<String> readInput() {
		List<String> list = new ArrayList<String>();
		try {
			BufferedReader input = new BufferedReader(new FileReader(
					INPUT_FILE_PATH));
			try {
				String line = null;

				while ((line = input.readLine()) != null) {
					list.add(line);
				}
			} finally {
				input.close();
			}
		} catch (IOException ex) {
			ex.printStackTrace();
		}
		
		return list;
	}

	public static void writeOutput(List<String> output) {
		PrintWriter writer = null;
		try {
			writer = new PrintWriter(new FileWriter(OUTPUT_FILE_PATH));
			for (String line : output) {
				writer.println(line);
			}
			writer.flush();
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			if (writer != null)
				writer.close();
		}
	}
	
	public static void main(String[] args) {
		List<DanceFloor> danceFloors = DanceFloor.parseFromFile(CodeJam.readInput());
		List<String> output = new ArrayList<String>();

		for(int i = 0; i < danceFloors.size(); i++) {
			System.out.println(danceFloors.get(i));
			String line = "";
			line += "Case #" + (i + 1) + ": " + danceFloors.get(i).calculate();
			output.add(line);
		}
		
		CodeJam.writeOutput(output);
	}
}

class DanceFloor {

	private List<Integer> tripletsTotalCounts;
	private int surpriseCount;
	private int targetScore;
	private int dancersCount;

	public DanceFloor(List<Integer> tripletsTotalCounts, int surpriseCount,
			int targetScore, int dancersCount) {
		this.tripletsTotalCounts = tripletsTotalCounts;
		this.surpriseCount = surpriseCount;
		this.targetScore = targetScore;
		this.dancersCount = dancersCount;
	}

	public int calculate() {
		int result = 0;
		
		if (targetScore == 0) return dancersCount;
		
		for (int i = 0; i < tripletsTotalCounts.size(); i++) {
			int total = tripletsTotalCounts.get(i);

			if (total < (targetScore * 3 - 4)) {
				tripletsTotalCounts.remove(i--);
			} else if (total == 0) {
				tripletsTotalCounts.remove(i--);
			}
		}
		
		for (int i = 0; i < tripletsTotalCounts.size(); i++) {
			int total = tripletsTotalCounts.get(i);

			if ((surpriseCount > 0) && (total == targetScore * 3 - 4)) {
				result++;
				surpriseCount--;
				tripletsTotalCounts.remove(i--);
			} else if ((surpriseCount == 0) && (total == targetScore * 3 - 4)) {
				tripletsTotalCounts.remove(i--);
			}
		}
		
		for (int i = 0; i < tripletsTotalCounts.size(); i++) {
			int total = tripletsTotalCounts.get(i);

			if ((surpriseCount > 0) && (total == targetScore * 3 - 3)) {
				result++;
				surpriseCount--;
				tripletsTotalCounts.remove(i--);
			} else if ((surpriseCount == 0) && (total == targetScore * 3 - 3)) {
				tripletsTotalCounts.remove(i--);
			}
		}
		
		result += tripletsTotalCounts.size();
		
		return result;
	}

	public static List<DanceFloor> parseFromFile(List<String> readInput) {
		List<DanceFloor> result = new ArrayList<DanceFloor>();
		int testCaseCount = Integer.parseInt(readInput.get(0));

		for (int i = 0; i < testCaseCount; i++) {
			String line[] = readInput.get(i + 1).split(" ");

			List<Integer> totalCounts = new ArrayList<Integer>();
			for (int j = 0; j < Integer.parseInt(line[0]); j++) {
				totalCounts.add(Integer.parseInt(line[3 + j]));
			}

			result.add(new DanceFloor(totalCounts, Integer.parseInt(line[1]),
					Integer.parseInt(line[2]), Integer.parseInt(line[0])));
		}

		return result;
	}

	@Override
	public String toString() {
		return "dancersCount = " + dancersCount + "; surpriseCount = " + surpriseCount 
								 + "; targetScore = " + targetScore + "; tripletsTotalCounts" 
								 + tripletsTotalCounts.toString();
	}
}


import java.io.*;
class Main
{
public static int dance(int ll,int spp,int maxx,int g[])
{

int c=0;
int l=ll;
long result[][]=new long[l][4];
int max=maxx;
//int g[]={15,13,11};
int s=0;
int i=0;
int sum=0;
int flag=0;
int t=2;
int presp=spp;
int special=0;
int sp=0;
int sol=0;int maxsol=0;int row=0;
int sum2=0;
boolean yes=true;
for(int loop=0;loop<l;loop++)
{
i=0;
while(i<=10 && flag==0)
{
for(int j=i;j<=i+t && flag==0;j++)
{
for(int k=i;k<=i+t && flag==0;k++)
{
sum=i+j+k;
if(sum==g[loop])
{
sum2=sum;
sol++;
if(j==i+2 || k==i+2)
{
sp++;
special++;
}
//System.out.println(sum+"  ... "+g[loop]);
if(i>=max || j>=max ||k>=max)
{
maxsol++;
//System.out.println(i+ "  "+j+"  "+k);
c++;
flag=0;
}
}

}
}
i++;


/*if(special==presp)
{
t=1;
special=0;
}*/
}
result[row][0]=sum2;
result[row][1]=sol;
result[row][3]=sp;
result[row][2]=maxsol;
row++;
flag=0;
sol=0;
maxsol=0;
sp=0;
}
//System.out.println("ans :"+c);
//System.out.println("special :"+special);
int ans=0;
sort(result,l);
for(int rr=0;rr<l;rr++)
{
if(result[rr][2]>0)
{
presp=rr+presp;
break;
}
}
//System.out.println("presp ="+presp);
for(int rr=0;rr<l;rr++)
{

if(result[rr][2]>0 )
{
if(rr>(presp-1))
{
if(result[rr][3]>=result[rr][2])
{
yes=false;
}
}

if(yes)
ans++;

yes=true;
}
/*
for(int cc=0;cc<4;cc++)
{
//System.out.print(result[rr][cc]+" |  ");
}
System.out.println();*/
}
//System.out.println("ans right:"+ans);
return ans;

}
public static void sort(long a[][],int l)
{
long cell1=0,cell2=0,cell3=0,cell4=0;
for(int i=0;i<l;i++)
{
for(int j=i+1;j<l;j++)
{
if(a[i][2]>a[j][2])
{
cell1=a[i][0];
cell2=a[i][1];
cell3=a[i][2];
cell4=a[i][3];

a[i][0]=a[j][0];
a[i][1]=a[j][1];
a[i][2]=a[j][2];
a[i][3]=a[j][3];

a[j][0]=cell1;
a[j][1]=cell2;
a[j][2]=cell3;
a[j][3]=cell4;

}

}
}
}
public static void main(String ar[]) throws IOException
{
FileReader in=new FileReader("hello.txt");
FileWriter ot=new FileWriter("check.txt",true);

BufferedReader ds=new BufferedReader(in);
BufferedWriter out=new BufferedWriter(ot);

//System.out.println("check332wefsd");
int loop=Integer.parseInt(ds.readLine());
String i[]=new String[loop];
int ll,maxx,sp;
int rs[];
int ans;
for(int ii=1;ii<=loop;ii++)
{
i=ds.readLine().split(" ");
ll=Integer.parseInt(i[0]);
sp=Integer.parseInt(i[1]);
maxx=Integer.parseInt(i[2]);
rs=new int[ll];
for(int j=3;j<ll+3;j++)
{
rs[j-3]=Integer.parseInt(i[j]);
}
ans=dance(ll,sp,maxx,rs);
out.write("Case #"+String.valueOf(ii)+": "+String.valueOf(ans));
out.newLine();

}
in.close();
out.close();

}
}