#include using namespace std; int a[1005]; int main(){ int T; scanf("%d",&T); while(T--){ int n1,n2,m; scanf("%d%d%d",&n1,&n2,&m); for(int i=1;i<=m;++i)scanf("%d",&a[i]); sort(a+1,a+m+1); bitset<100005>bs; bs[1]=1; int ans=0,he=0; for(int i=1;i<=m;++i){ bs|=bs<n1+n2)break; if((signed)bs._Find_next(max(0,he-n2))>n1+1)break; ans=i; } printf("%d\n",ans); } return 0; }