package googlers;

import java.util.Scanner;
import java.util.PriorityQueue;
import java.util.Comparator;
public class Googlers {
	
	public static void main(String[] args) {
		
		int n,s,p,count=0,t;		
		Scanner sin=new Scanner(System.in);
		
		t=Integer.parseInt(sin.nextLine());
		
		
		int result[]=new int[t];
		int j=0;
		
		if(t>=1 && t<=100)
		{
		for (int k = 0; k < t; k++) {
		count=0;	
		
			
        String ip = sin.nextLine();
        
        String[]tokens=ip.split(" ");
		
		
		n=Integer.parseInt(tokens[0]);
		s=Integer.parseInt(tokens[1]);
		p=Integer.parseInt(tokens[2]);
		
		if( (s>=0 && s<=n) && (p>=0 && p<=10) )
		{
		int[] total=new int[n];
		
		
		for (int i = 0; i < n; i++)
        {
            total[i] = Integer.parseInt(tokens[i+3]);
        }
		
		Comparator comparator=new PointComparator();
		PriorityQueue pq=new PriorityQueue<Point>(1, comparator);
		
		for (int i = 0; i < n; i++)
		{
			
			int x=total[i]/3;
			int r=total[i]%3;
			if(x>=p)
				count++;
			else if(x<(p-2))
				continue;
			else
			{
				//System.out.println("enter "+x+" "+(p-2));
				if(p-x==1)
				{
					Point temp=new Point();
					temp.q=x;
					temp.r=r;
					pq.add(temp);
				}
				else  // p-x=2
				{
					if(r==0)
						continue;
					else
					{
						Point temp=new Point();
						temp.q=x;
						temp.r=r;
						pq.add(temp);
					}				
					
				}
					
			}
			//System.out.println("hi "+pq.size());
			
		}
		
		
		
		while(pq.size()!=0)
		{
			Point temp=(Point)pq.remove();
			if(p-temp.q==1 && temp.q!=0)
			{
				if(temp.r>=1)
					count++;
				else
				{
					if(s!=0)
					{
						s--;
						count++;
					}
				}
			}
			else if(p-temp.q==2)
			{
				if(s!=0 && (temp.q+temp.r)>=p)
				{
					s--;
					count++;
				}
			}
			
				
		}
		
		//System.out.println(p);
		
		result[j++]=count;
		
		}
		}
		
		for (int i = 0; i < t; i++) 
		{
			System.out.println("Case #"+(i+1)+": "+result[i]);
		}
		}
		
	}
        
        
		
		/*Point x=new Point();
		x.q=8;
		Point y=new Point();
		y.q=6;
		Point z=new Point();
		z.q=7;
		
		pq.add(x);
		pq.add(y);
		pq.add(z);
		*/
		
		
		
		
	

}

class PointComparator implements Comparator<Point>
{
    @Override
    public int compare(Point x, Point y)
    {
        // Assume neither string is null. Real code should
        // probably be more robust
        if (x.q < y.q)
        {
            return 1;
        }
        if (x.q  > y.q)
        {
            return -1;
        }
        return 0;
    }
}



class Point
{
	int q,r;

	public int getQ() {
		return q;
	}

	public void setQ(int q) {
		this.q = q;
	}

	public int getR() {
		return r;
	}

	public void setR(int r) {
		this.r = r;
	}
	
	
}

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.File;
import java.io.PrintStream;
import java.util.Scanner;
import java.util.Arrays;
import java.util.ArrayList;

public class Dancers{   
  public static ArrayList<Triplet> scores;
  
  public static void main(String arg[]){
    System.out.print("Enter the file path of the input file : ");
    String path = new Scanner(System.in).nextLine();
    String ANS ="", output="", test;
    int diff;
    
    try{
      Scanner read = new Scanner(new File(path));
      int testCases =  Integer.parseInt(read.nextLine());
      int cn=0; String tongue; 
      while(cn++<testCases){
        test  = read.nextLine();
        
        output = "Case #"+cn+": "+ solve(test);//WRITE ANS TO DIFFERENT FILE 
        ANS += output +" \n";
        System.out.println(ANS);
      }
      writeToFile("dancers.out",ANS);
    }
    catch(FileNotFoundException e){//if file is not found
      System.err.println("data file \'"+path+"\' was not found\nPress <enter> to exit...");
      (new Scanner(System.in)).nextLine();
      System.exit(1);
    }
  }
  
  public static void writeToFile(String file, String text){
    PrintStream out = null;
    try {
      out = new PrintStream(new FileOutputStream(file));
      out.print(text);
    }
    catch(Exception e){}
    finally {
      if (out != null) out.close();
    }   
  }
  
  public static int solve(String test){
    String temp[] = test.split(" ");
    ArrayList<Triplet> tempList = new ArrayList<Triplet>();
    Triplet[] scores;
    int dancerNo, surpriseNo, bestResult;
      
    dancerNo = Integer.parseInt(temp[0]);
    surpriseNo = Integer.parseInt(temp[1]);
    bestResult = Integer.parseInt(temp[2]);
    int counter = 0;
    
    while(counter < dancerNo){
      tempList.add(new Triplet(temp[3+counter])); 
      counter++;
    }
    
    scores = tempList.toArray(new Triplet[tempList.size()]);
    
    
    Arrays.sort(scores);
    
    scores = doTheSurprises(scores,surpriseNo, bestResult);  
    
    System.out.println(Arrays.toString(scores));
    
    return count(scores, bestResult);
  }
  
  public static Triplet[] doTheSurprises(Triplet sc[], int surprise, int max){
    Triplet temp;
    int sNo=0;
    for(int i=sc.length-1; i>=0; i--){
      if(sNo==surprise){
        break;
      }
      
      if(sc[i].scores[2]<max){
        if(sc[i].doSurprise()){
          sNo++;
        }
      }
    }    
    return sc;
  }
  
  public static int count(Triplet sc[], int max){
    int temp=0;
    for(int i=0; i<sc.length; i++){
      if(sc[i].scores[2]>=max){
        temp++;
      }
    }
    return temp;}
}

class Triplet implements Comparable<Triplet>{
  public int scores[] = new int[3];
  public Triplet(int x, int y, int z){
    scores[0]=x;
    scores[1]=y;
    scores[2]=z;
  }
  
  public Triplet(String x){setThrees(Integer.parseInt(x));}
  
  public Triplet(int x){setThrees(x);}
  
  public void setThrees(int numb){
    this.scores[0] =numb/3;
    this.scores[1] = (numb-scores[0])/2;
    this.scores[2] = numb - scores[0] - scores[1];
  } 
  
  public int compareTo(Triplet x){
    if(scores[2]<x.scores[2]){
      return -1;
    }
    else if(scores[2]>x.scores[2]){
      return 1;
    }
    else{
      return 0;
    }
    
  }
  
  public boolean doSurprise(){
    int s1 = scores[1], s2 = scores[2];
    
    if(s1 == s2){
      s1--; s2++;
      if(s1>=0 && s2<=10){
        scores[1] = s1;
        scores[2] = s2;
        return true;
      }
    }
    return false;
  }
  
  public String toString(){
    return Arrays.toString(scores);
  }
}
