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):
	n = abs(int(n))
	if n < 2:return False
	if n == 2:return True    
	if not n & 1:return False
	for x in range(3, int(n**0.5)+1, 2):
		if n % x == 0:
			return False
	return True
def sum_digits(n):
	s = 0
	while n:
		s += n % 10
		n /= 10
	return s
t=input()
while t>0:
	t-=1
	n=input()
	k=sum_digits(n)
	if isprime(n):
		if isprime(k):
			print "YES"
		else :
			print "NO"
	else:
		print "NO"