#include <iostream>
using namespace std;

int mjera (int q, int w) {
  if (w==0) return q;
  else return mjera(w,q%w);
}


int main () {
  int i,j,n,k,a[100],b[100],m;
  cin >> n >> k;
  
  m=360;
  for (i=1; i<=n; i++) {
      cin >> a[i];
      if (a[i]>m) m=mjera(a[i],m); 
      else m=mjera(m,a[i]);
  }
  for (i=1; i<=k; i++)
    cin >> b[i];
    
  for (i=1; i<=k; i++)
    if (b[i]%m==0) cout << "DA" << endl;
    else cout << "NE" << endl;
    
   //system ("pause");
   return 0;
} 
