#include<iostream>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<algorithm>
using namespace std;
vector<int>meizilist;
int main()
{
int num;
cin>>num;
for(int i=0;i<num;i++)
{
int time,meizi_num,meet_num=0;
cin>>time>>meizi_num;
meizilist.resize(meizi_num);
for(int i=0;i<meizi_num;i++)
{
cin>>meizilist[i];
}
sort(meizilist.begin(),meizilist.end());
int it=0;
while(it<meizilist.size())
{
time-=meizilist[it++];
meet_num++;
if(time==0)
break;
else if(time<=0)
{
meet_num--;
break;
}
}
cout<<meet_num<<endl;
}
}