def rec(i, r1): #if dp[i][r1] != -1: # return dp[i][r1] r2 = n1 + n2 - Asum[i - 1] - r1 if i == m: res = 0 elif max(r1, r2) < A[i]: res = 0 elif r1 < A[i] and A[i] < r2: res = rec(i + 1, r1) + 1 elif r2 < A[i] and A[i] < r1: res = rec(i + 1, r1 - A[i]) + 1 else: res = max(rec(i + 1, r1), rec(i + 1, r1 - A[i])) + 1 #dp[i][r1] = res return res d = int(input()) for _ in range(d): n1, n2 = map(int, input().split()) m = int(input()) A = sorted(map(int, input().split())) Asum = [] Asum.append(A[0]) for i in range(1, m): Asum.append(Asum[i - 1] + A[i]) #print(Asum) #dp = [[-1 for r1 in range(100001)] for i in range(61)] print(rec(0, n1))