# include <stdio.h>
#include<stdlib.h>
int comp(const void *p,const void *q){
return (*(int*)p-*(int *)q);
}
int main()
{
int t,n,m,time[100],count=0;
int i,j;
scanf("%d",&t);
for(i=0;i<t;i++){
count=0;
scanf("%d%d",&n,&m);
for(j=0;j<m;j++){
scanf("%d",&time[j]);
}
qsort(time,m,sizeof(int),comp);
for(j=0;j<m;j++){
n-=time[j];
if(n>=0)
count++;
else
break;
}
if(i==t-1)
printf("%d",count);
else
printf("%d\n",count);
}
return 0;
}