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=input()
for i in xrange(t):
    n=raw_input()
    m=int(n)
    s=0
    flag=0
    temp=0
    for x in xrange(2,m):
        if m%x==0:
            flag=0
            break
    else:
        flag=1
    for j in n:
        k=int(j)
        s=s+k
    if s!=1:
        for l in xrange(2,s):
            if s%l==0:
                temp=0
                break
        else:
            temp=1
    if temp==1 and flag==1:
        print "YES"
    else:
        print "NO"