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

def isprime(m):
	if m<2:
		return False
	if m==2:
		return True
	r = 2
	while r <= int(sqrt(m))+1:
		if m%r==0:
			return False
		r += 1
	return True

def sod(m):
	t = 0
	while m:
		t += m%10
		m /= 10
	return t

def isdual(m):
	if isprime(sod(m)):
		if isprime(m):
			return True
	return False


t = input()
while t:
	t -= 1
	r = input()
	if isdual(r):
		print "YES"
	else:
		print "NO"