#include<stdio.h>
#include<string.h>
int main(){
int T,n,m,i,num,time,temp,pass,total,q;
int ss[200];
scanf("%d",&T);
while(T--){
scanf("%d %d",&n,&m);
num=0;
total=0;
for(i=0;i<m;++i){
scanf("%d",&time);
ss[i]=time;
}
for(pass=1;pass<m;++pass){
for(i=0;i<m-pass;++i){
if(ss[i]>ss[i+1]){
temp=ss[i];
ss[i]=ss[i+1];
ss[i+1]=temp;
}
}
}
for(q=0;q<m;++q){
total+=ss[q];
if(total<=n)
num+=1;
}
printf("%d\n",num);
}
return 0;
}