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
import math

cnt=0
def sum_digits(n):
    s = 0
    while n:
        s += n % 10
        n /= 10
    return s
def is_prime(n):
    if n % 2 == 0 and n > 2: 
        return False
    return all(n % i for i in range(3, int(math.sqrt(n)) + 1, 2))
for i in xrange(input()):
    n=input('')
    if is_prime(int(n)):
        p=sum_digits(int(n))
        if is_prime(p):
            print "YES"
        else:
            print "NO"
    else:
        print "NO"