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