import java.io.*; import java.util.*; import java.util.stream.*; public class Main { static int n1; static int n2; static int[][] dp; static int[] values; public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); int n = sc.nextInt(); StringBuilder sb = new StringBuilder(); while (n-- > 0) { n1 = sc.nextInt(); n2 = sc.nextInt(); values = new int[sc.nextInt()]; for (int i = 0; i < values.length; i++) { values[i] = -sc.nextInt(); } Arrays.sort(values); dp = new int[values.length][n1 + 1]; for (int[] arr : dp) { Arrays.fill(arr, -1); } sb.append(dfw(values.length - 1, n1, n2)).append("\n"); } System.out.print(sb); } static int dfw(int idx, int a, int b) { if (idx < 0) { return 0; } if (values[idx] + a < 0 && values[idx] + b < 0) { return 0; } if (dp[idx][a] < 0) { if (values[idx] + a < 0) { dp[idx][a] = dfw(idx - 1, a, b + values[idx]) + 1; } else if (values[idx] + b < 0) { dp[idx][a] = dfw(idx - 1, a + values[idx], b) + 1; } else { dp[idx][a] = Math.max(dfw(idx - 1, a, b + values[idx]), dfw(idx - 1, a + values[idx], b))+ 1; } } return dp[idx][a]; } } class Utilities { static String arrayToLineString(Object[] arr) { return Arrays.stream(arr).map(x -> x.toString()).collect(Collectors.joining("\n")); } static String arrayToLineString(int[] arr) { return String.join("\n", Arrays.stream(arr).mapToObj(String::valueOf).toArray(String[]::new)); } } class Scanner { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); StringBuilder sb = new StringBuilder(); public Scanner() throws Exception { } public int nextInt() throws Exception { return Integer.parseInt(next()); } public long nextLong() throws Exception { return Long.parseLong(next()); } public double nextDouble() throws Exception { return Double.parseDouble(next()); } public int[] nextIntArray() throws Exception { return Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray(); } public String next() throws Exception { while (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } return st.nextToken(); } }