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
t=int(raw_input(''))
sum=0
l=0
for i in range(0,t):
    a=int(raw_input(''))
    for k in range(2,int(a/2)+1):
        if a%k==0:
            l=1
            break
    if l==1:
        print 'NO'
    if l==0:
        a=str(a)
        p=len(a)
        for d in range(0,p):
            sum=sum+int(a[d])
        for k in range(2,int(sum/2)+1):
            if sum%k==0:
                j=0
                break
        if sum==2:
            print 'YES'
        else:
            if j==0:
                print 'NO'
            else:
                print 'YES'
    sum=0
    l=0
    j=1