while True:
try:
a = int(input())
for i in range(a):
print("Yes!" if sum(map(lambda c: 0 <= c <= 255, map(int, input().split(".")))) == 4 else "No!")
except:
break
def fun2():
ips = [raw_input() for _ in range(input())]
for ip in ips:
print 'Yes!' if all(map(lambda x: 0 <= int(x) <= 255, ip.split('.'))) else 'No!'
while True:
try:
fun2()
except EOFError:
break