#include<iostream>
using namespace std;
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int t;
cin>>t;
while(t--)
{
int weigh;
cin>>weigh;
int k;
cin>>k;
int w[k],l[weigh+1]={0};
for(int i=0;i<k;i++) cin>>w[i];
for(int i=0;i<k;i++)
{
for(int j=weigh;j>=0;j--)
{
if(j<w[i]) break;
if(l[j]<l[j-w[i]]+w[i]) l[j]=l[j-w[i]]+w[i];
}
}
//cout<<l[weigh]<<"\n";
if(l[weigh]==weigh) cout<<"YES\n";
else cout<<"NO\n";
}
}
AC (2ms, 360KB) |