d = int(input()) def calc(a,b,m,A): S = 0 dp = [0] * (a + 1) dp[0] = 1 A.sort() S = A[0] if S > a and S > b: return 0 if S <= a: dp[S] = 1 ans = 1 for i in range(1,m): S += A[i] if S > a + b: return ans flag = False for k in range(a - A[i],-1,-1): dp[k + A[i]] |= dp[k] for k in range(S - b,a + 1): if dp[k]: flag = True break if flag: ans += 1 else: return ans return m for _ in range(d): a,b = map(int,input().split()) m = int(input()) A = list(map(int,input().split())) print(calc(a,b,m,A))