#include #include #include #include #include #include #include #define inf 999999999 #define mo 1000000007 #define LL long long using namespace std; const int maxn=9999; int a[maxn],b[maxn],n; int num[maxn]; int sum; int main() { int t,x,m,flag; cin>>t; while (t--) { cin>>n; memset(a,0,sizeof(a)); memset(b,0,sizeof(b)); sum=0;a[0]=1; for (int i=1;i<=n;i++) cin>>num[i]; for (int i=1;i<=n;i++) { x=num[i]; for (int j=sum;j>=0;j--) a[j+x]=max(a[j+x],a[j]); a[x]=1; sum+=x; } for (int i=1;i<=n;i++) { x=num[i]; for (int j=x;j<=sum;j++) a[j-x]=max(a[j-x],a[j]); } cin>>m; for (int i=1;i<=m;i++) { cin>>x; if (a[x]) cout<<"YES"<