#include<bits/stdc++.h>
using namespace std;
int comp(const void *p, const void *q) {
return (*(int *)p - *(int *)q);
}
int main() {
int T;
cin >> T;
while(T--) {
int n, m;
int time[100] = {0};
int count = 0;
cin >> n >> m;
for(int i = 0; i < m; i++)
cin >> time[i];
qsort(time, m, sizeof(int), comp);
int sum = 0;
for(int i = 0; i < m; i++) {
sum += time[i];
if (sum > n)
break;
count++;
}
cout << count << endl;
}
return 0;
}