import java.util.Arrays; import java.util.Scanner; public class Yuki393 { static Scanner sc = new Scanner(System.in); public static void main(String[] args) { int d = sc.nextInt(); for (int i = 0; i < d; i++) { System.out.println(solve()); } } static int solve() { int n1, n2; n1 = sc.nextInt(); n2 = sc.nextInt(); int m = sc.nextInt(); int[] A = new int[m]; for (int i = 0; i < m; i++) { A[i] = sc.nextInt(); } Arrays.sort(A); int[][] dp = new int[m + 1][n1 + 1]; for (int i = 0; i < m + 1; i++) { Arrays.fill(dp[i], -1); } dp[0][n1] = n2; for (int i = 0; i < m; i++) { boolean f = false; for (int j = 0; j < dp[i].length; j++) { if (dp[i][j] == -1) continue; if (dp[i][j] - A[i] >= 0) { dp[i + 1][j] = dp[i][j] - A[i]; f = true; } if (j - A[i] >= 0) { dp[i + 1][j - A[i]] = dp[i][j]; f = true; } } if (!f) return i; } return m; } }