#include<iostream>
#include<fstream>
#include<algorithm>
#include<string.h>
#include<string>
using namespace std;
int main(){
int T,n,m,a[101],sum,count;
cin>>T;
while(T--){
sum=0;
count=0;
cin>>n>>m;
for(int i=0;i<m;i++){
cin>>a[i];
}
sort(a,a+m);
for(int i=0;i<m;i++){
sum=sum+a[i];
if(sum<=n)
count=count+1;
else
break;
}
cout<<count<<endl;
}
return 0;
}