test=input()
while test>0:
	test=test-1
	s=map(int,list(raw_input()))
	ind=[0,0,1,1,0,1,0,1,0,0,0,1,0,1,0,0,0,1,0,1,0,0,0,1,0,0,0,0,0,1,0,1,0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0,1,0,0]
	n=0
	for i in s:
		n=n+i
	if ind[n]!=1:
		print "NO"
	else:
		print "YES"