# your code goes here


def splended_symbols(N):
	for i in range(N):
		symbols = input()
		if (len(symbols) > 39) or ("39" in symbols or "93" in symbols or "999" in symbols):
			print("Yes")
		else:
			print("No")
			
			
splended_symbols(int(input()))
print("bareera")
splended_symbols(int(input()))
print("bareera")
splended_symbols(int(input()))
print("bareera")
splended_symbols(int(input()))