#include<cstdio>
#include<cctype>
#define rg register
using namespace std;
const int N = 1e7 + 1;
int n, m, v[N], prime[N], tot;
bool is_prime[N];
inline int read(){
rg char ch = getchar();
rg int f = 0, x = 0;
while(!isdigit(ch)) f |= (ch == '-'), ch = getchar();
while( isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
return f ? -x : x;
}
inline void get_prime(){
for(rg int i = 2; i <= n; ++i){
if(!v[i]){
v[i] = i;
prime[++tot] = i;
is_prime[i] = true;
}
for(rg int j = 1; j <= tot; ++j){
if(prime[j] > v[i] or prime[j] * i > n) break;
v[prime[j] * i] = prime[j];
}
}
}
signed main(){
n = read(), m = read();
get_prime();
for(rg int i = 1, tmp; i <= m; ++i){
tmp = read();
if(is_prime[tmp]) puts("Yes");
else puts("No");
}
return 0;
}