#include <iostream>
#include <string>
#include <vector>
using namespace std;

bool jeliuperiodu(int k, int r) {

    int i=k;
    


        while(k>360) k-=360;
        while(k<0) k+=360;        
    
        while(r>360) r-=360;
        while(r<0) r+=360;    

    if (k == r) return true;
    
    while(true) {
        i+= k;
        while(i>360) i-=360;
        while(i<0) i+=360;
        
        if(i==r) return true;
        if(i==k) { break;}
        }
        
    return false;
}

int n,m,k,i,j;
int konstr[10];
int isp[10];


int main() {

    cin >> n >> k;
    
    for(i=0; i < n; i++)
        cin >> konstr[i];
        
    for(i=0; i < k; i++)
        cin >> isp[i];

    vector<int> moguci;
    
    int perm=1;
    for(i = 0; i < n; i++)
        perm *= 3;
        
    for(i=0; i <= perm; i++) {
        int t = 0;
        
        int cp = i;
        for(int j = 0; j < n; j++) {
            if((cp % 3) == 1) t -= konstr[j];
            if((cp % 3) == 2) t += konstr[j];
            cp /= 3; }
            
        while(t>360) t-=360;
        while(t<0) t+=360;  
            
        moguci.push_back(t); }
        

    for(int t = 0; t < k; t++) {
        bool post = false;
        
    for(i=0; i < moguci.size(); i++) 
        if(jeliuperiodu(moguci[i],isp[t])) { cout << "DA" << endl; post = true; break; }
         
    
    if(!post) cout << "NE" << endl; }
            
   

//system("pause");

}   
    
    
