#include<iostream>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<cstring>
#include<string>
using namespace std;
bool isprime[10000005];
void sc(int p)
{
    memset(isprime, true, sizeof(isprime));
    isprime[0] = isprime[1] = false;
    for (int i = 2; i<=p; ++i)
    {
        if (isprime[i]==0) 
            continue;
        for (int j = i + i; j<=p; j += i)
        {
            isprime[j] = false;
        }
    }
}
int main()
{
    int n = 0, m = 0, a[100005] = {0};
    scanf("%d%d", &n, &m);
    sc(n);
    for(int i=1;i<=m;i++)
    {
        scanf("%d",&a[i]);
    }
    for (int i = 1; i <= m; ++i)
    {
        if (isprime[a[i]]==true)
        {
            printf("Yes\n");
        }
        else
        {
            printf("No\n");
        }
    }
    return 0;
}