#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
int t;
cin >> t;
while(t--) {
int n,m;
cin >> n >> m;
int *a = new int[m];
for (int i=0;i<m;i++) {
cin >> a[i];
}
sort(a,a+m);
int count = 0;
int pos = 0;
while(pos < m) {
n -= a[pos++];
if (n < 0)
break;
count++;
}
cout << count << endl;
}
}