a number can be said dual prime. if the number is prime and the sum of digits of the number is also a prime number.
If a number is dual prime then print YES else print NO

SAMPLE INPUT
2
13
11

SAMPLE OUTPUT
NO
YES
def primes(n):
    """ Returns  a list of primes < n """
    sieve = [True] * n
    for i in xrange(3,int(n**0.5)+1,2):
        if sieve[i]:
            sieve[i*i::2*i]=[False]*((n-i*i-1)/(2*i)+1)
    return [2] + [i for i in xrange(3,n,2) if sieve[i]]
lis= primes(1000000)
#print lis
t=int(raw_input())
for i in xrange(t):
    n=int(raw_input())
    if n in lis:
        s=str(n)
        l=list(s)
        li=map(int,l)
        if(sum(li) in lis):
            print "YES"
        else:
            print "NO"
    else:
        print "NO"