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 check(n):
    d =True
    if n==1 or n==0:
        return False
    else:
        for i in range(2,n):
            if n%i==0:
                return False
    return d
        
    
for _ in range(int(raw_input())):
    n=int(raw_input())
    temp=n
    su=0
    while(temp):
        
        su+=temp%10
        temp=temp//10
    
    #print(su)
    if check(su) and check(n):
        print("YES")
    else:
        print("NO")