// Arup Guha
// 4/23/2024
// Solution to Spring 2024 COP 3503 Final Exam Question #9

import java.util.*;

public class q9 {

	public static void main(String[] args) {
	
		// Read in number of cases.
		Scanner stdin = new Scanner(System.in);
		int nC = stdin.nextInt();
		
		// Process cases.
		for (int loop=0; loop<nC; loop++) {
			
			// Get input.
			int n = stdin.nextInt();
			long money = stdin.nextLong();
			long[] prices = new long[n];
			for (int i=0; i<n; i++)
				prices[i] = stdin.nextLong();
			
			// Run it.
			System.out.println(getMaxBooks(prices, money));
		}
	
	
	}

	public static int getMaxBooks(long[] bookprices, long money) {
	
		// These need to be sorted so we can buy cheaper books first, greedily.
		Arrays.sort(bookprices);
		int res = 0;
		long zeroCost = 0, oneCost = 0;
		
		// We'll go every other book.
		for (int i=0; i<bookprices.length; i+=2) {
			
			// Here we buy books in the even indexes, 0, 2, 4, etc.
			// We'll have an odd number of books in this case.
			if (zeroCost + bookprices[i] <= money) {
				zeroCost += bookprices[i];
				res = Math.max(res, i+1);
			}
			
			// Here we buy books in the odd indexes, 1, 3, 5, etc.
			// And an even number of books in this case.
			if (i+1<bookprices.length && oneCost + bookprices[i+1] <= money) {
				oneCost += bookprices[i+1];
				res = Math.max(res, i+2);
			}
		}
		
		// Ta da!
		return res;
	}
	
}