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 prime(x):
	i=2
	while i*i<=x:
		if x%i==0:
			return False
		i+=1
	return True	
for _ in range(input()):
	n=input()
	if prime(n)==False:
		print 'NO'
		continue
	else:
		rev=0
		while n:
			x=n%10
			rev=rev+x
			n=n/10
	#	print rev	
		if prime(rev)==True:
			print 'YES'
		else:print 'NO'