d = int(input()) for _ in range(d): n1, n2 = map(int, input().split()) input() A = sorted(map(int, input().split())) ans = 0 syugo = {(n1, n2)} for a in A: print("a = {}".format(a)) if syugo == set(): break new_syugo = set() for x, y in syugo: if x - a >= 0: new_syugo.add((x - a, y)) if y - a >= 0: new_syugo.add((x, y - a)) syugo = new_syugo print(syugo) ans += 1 print(ans - 1)