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
#!/usr/bin/python
def isprime(n):
    if n==1:
     return 0
    if n==2:
     return 1
    if n%2==0:	
	 return 0
    N=long(n**0.5)+1
    for i in range(3,N,2):
     if n%i==0:
	return 0
    return 1
	
for t in range(input()):
	n=int(raw_input())
	if isprime(n)==1:
		z=n
		su=0
		while z>0:
			su=su+z%10
			z=z/10
		if isprime(su)==1:
			print "YES"
		else:
			print "NO"
	else:
		print "NO"