import sys input = sys.stdin.readline t=int(input()) for tests in range(t): n1,n2=map(int,input().split()) m=int(input()) A=list(map(int,input().split())) A.sort() OK=0 NG=m+1 while NG>OK+1: mid=(OK+NG)//2 B=A[:mid] SUM=sum(B) if SUM>n1+n2: NG=mid continue NOW=1 for b in B: NOW|=(NOW<