#include #include #include #include #define valid(x) (x >= 2000 - totw && x <= 2000 + totw) using namespace std; bool dp[30][4100]; void solve(){ int totw = 0,N,M,w[30],x; scanf("%d",&N); for(int i = 1; i <= N; i++){ scanf("%d",&w[i]); totw += w[i]; } scanf("%d",&M); memset(dp,false,sizeof(dp)); dp[0][2000] = true; for(int i = 1; i <= N; i++){ for(int j = 2000 - totw; j <= 2000 + totw; j++){ dp[i][j] = dp[i-1][j]; if(valid(j+w[i])) dp[i][j] = dp[i][j] || dp[i-1][j+w[i]]; if(valid(j-w[i])) dp[i][j] = dp[i][j] || dp[i-1][j-w[i]]; if(valid(w[i]-j)) dp[i][j] = dp[i][j] || dp[i-1][w[i]-j]; } } for(int i = 1; i <= M; i++){ scanf("%d",&x); if(dp[N][x+2000] || dp[N][2000-x]){ puts("YES"); } else puts("NO"); } } int main(){ int T; scanf("%d",&T); while(T--){ solve(); } return 0; }