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