#include <bits/stdc++.h>
using namespace std;
struct xor_128 {
unsigned x,y,z,w;
xor_128(): x(89165727), y(157892372), z(7777777), w(757328) {}
unsigned next() {
unsigned t=x^(x<<11);
x=y;y=z;z=w;
return w=w^(w>>19)^t^(t>>8);
}
unsigned next(unsigned k) {
return next()%k;
}
}rng;
int n;
int a[1<<14];
vector <int> primes;
bool is_prime(int a) {
if(a<2) return false;
if(a==2) return true;
int sq=sqrt(a),i;
for(i=2;i<=sq;i++) if(a%i==0) return false;
return true;
}
bool check(int a) {
int i;
vector <int> v;
for(i=0;i<(int)(primes.size());i++) {
if((a|primes[i])==a) v.push_back(primes[i]);
}
if(v.size()==0) return false;
for(i=1;i<=8000;i++) {
int i1,i2,i3,i4;
i1=rng.next(v.size());i2=rng.next(v.size());i3=rng.next(v.size());i4=rng.next(v.size());
if((v[i1]|v[i2]|v[i3]|v[i4])==a) return true;
}
return false;
}
int main() {
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
int i;
for(i=1;i<=8000;i++) if(is_prime(i)) primes.push_back(i);
scanf("%d", &n);
for(i=1;i<=n;i++) {
scanf("%d", &a[i]);
if(check(a[i])) printf("YES\n");
else printf("NO\n");
}
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+Cgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKc3RydWN0IHhvcl8xMjggewoJdW5zaWduZWQgeCx5LHosdzsKCXhvcl8xMjgoKTogeCg4OTE2NTcyNyksIHkoMTU3ODkyMzcyKSwgeig3Nzc3Nzc3KSwgdyg3NTczMjgpIHt9Cgl1bnNpZ25lZCBuZXh0KCkgewoJCXVuc2lnbmVkIHQ9eF4oeDw8MTEpOwoJCXg9eTt5PXo7ej13OwoJCXJldHVybiB3PXdeKHc+PjE5KV50Xih0Pj44KTsKCX0KCXVuc2lnbmVkIG5leHQodW5zaWduZWQgaykgewoJCXJldHVybiBuZXh0KCklazsKCX0KfXJuZzsKCmludCBuOwppbnQgYVsxPDwxNF07CnZlY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