#include<stdio.h>
#include<math.h>
int main(void){
int time[1000];
int T,n,m,a,b;
int i,j,c;
int newtime;
scanf("%d",&T);
while(T--){
scanf("%d%d",&n,&m);
c=m;
for(i=0;i<m;i++){
scanf("%d",&a);
time[i]=a;
}
while(m--){
for(i=1;i<c;i++){
newtime=time[i-1];
if(time[i]<time[i-1]){
time[i-1]=time[i];
time[i]=newtime;
}
}
}
b=0;
for(i=0;i<c;i++){
n=n-time[i];
if(n<0)
break;
else
b++;
}
printf("%d\n",b);
}
return 0;
}