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 isPrime(n):
    '''check if integer n is a prime'''
    # make sure n is a positive integer
    n = abs(int(n))
    # 0 and 1 are not primes
    if n < 2:
        return False
    # 2 is the only even prime number
    if n == 2: 
        return True    
    # all other even numbers are not primes
    if not n & 1: 
        return False
    # range starts with 3 and only needs to go up the squareroot of n
    # for all odd numbers
    for x in range(3, int(n**0.5)+1, 2):
        if n % x == 0:
            return False
    return True
def sum_digits(n):
    n=int(n)
    r = 0
    while n:
        r, n = r + n % 10, n / 10
    return r
    
t=input()
while t:
    flag=0
    num=raw_input()
    if(isPrime(num)):
        flag+=1
    summ=sum_digits(num)
    if(isPrime(summ)):
        flag+=1
    t=t-1
    if(flag==2):
        print "YES"
    else:
        print "NO"