for _ in range(int(input())):
num = int(input())
if str(num * num).endswith(str(num)):
print("YES")
else:
print("NO")
for _ in range(int(input())):
num = int(input())
if str(num * num).endswith(str(num)):
print("YES")
else:
print("NO")