#include <stdio.h>
#include <string.h>
#define max(a,b) (a)>(b)?(a):(b)
int main(){
int n,m,t,i,dp[10001];
int j;
int time[101];
scanf("%d",&t);
while (t--){
memset(dp,0,sizeof(dp));
scanf("%d%d",&n,&m);
for (i=1;i<=m;i++){
scanf("%d",&time[i]);
}
for (i=1;i<=m;i++){
for (j=n;j>=time[i];j--){
dp[j]=max(dp[j],dp[j-time[i]]+1);
}
}
printf("%d\n",dp[n]);
}
return 0;
}