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
from math import sqrt
t=input()
def idPrime(n):
	for i in range(2,int(sqrt(n)+1)):
		if n%i==0:return 0
	return 1	
for _ in range(t):
	n=input()
	isdp=idPrime(sum(map(int,str(n)))) and idPrime(n)
	if isdp: print "YES"
	else: print "NO"