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

    return True
for tc in range(int(raw_input())):
	n=int(raw_input())
	su=0
	if isPrime(n):
		while n>0:
			su+=n%10
			n=n/10
		if isPrime(su):
			print 'YES'
		else:
			print 'NO'
	else:
		print'NO'