#include <iostream>
#include <queue>

#include <cstdio>
#include <cstring>
#include <cmath>

using namespace std;

int main () {
    int n, s, i, j, k, q;
    bool ok;
    queue<string> sol;
    string DA = "DA", NE = "NE";
    scanf("%d %d", &n, &k);
    int a[n], b;
    for (i=0; i<n; i++) scanf("%d", &a[i]);
    while (k) {
        scanf("%d", &b);
        k--;
        s = 0;
        ok = 1;
        q = 1;
        i = 0;
        for (i=0; i<n; i++) {
            s = 0;
            while (s != 360) {
                  s += a[i];
                  if (s == b or s % 360 == b) {sol.push(DA); ok = 0; if (!ok) break;}
                  if (s > 360) s -= 360;
            }
            if (!ok) break;
        }
        if (ok) {
        for (i=0; i<n; i++) {
            for (j=0; j<n; j++) {
                //if (!(b % a[j])) {sol.push(DA); ok = 0; if (!ok) break;}
                if (a[i] + a[j] == b) {sol.push(DA); ok = 0; if (!ok) break;}
                if (a[i] - a[j] == b or a[j] - a[i] == b) {sol.push(DA); ok = 0; if (!ok) break;}
            }
            if (!ok) break;
        }
        }
        if (ok) sol.push(NE);
    }
    while (!sol.empty()) {
          cout << sol.front() << endl;
          sol.pop();
    }
  //  system("pause");
    return 0;
}
