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