#include<stdio.h>
int main(void){
int i,j,a[105],T,n,m,sum,q,temp;
scanf("%d",&T);
while(T--){
scanf("%d %d",&n,&m);
for(i=0;i<m;i++){
scanf("%d",&a[i]);
}
for(j = 0;j<m;j++){
for(i = 0;i<m-j-1;i++){
if(a[i]>a[i+1]){
temp = a[i];
a[i] = a[i+1];
a[i+1] = temp;
}
}
}
for(i=0;i<m;i++){
n = n-a[i];
if(n<0){
printf("%d\n",i);
break;
}
if(i==m-1)
printf("%d\n",i+1);
}
}
return 0;
}