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):
    if n<2:
    	return False
    for i in range(2,int(n**0.5)+1):
        if n%i==0:
            return False

    return True

t=input()
for _ in range(t):
	n=input()
	if (isPrime(n)):
		s=sum(map(int, str(n)))
		if (isPrime(s)):
			print"YES"
		else:
			print"NO"
	else :
		print "NO"