import sys input = sys.stdin.readline def f(n): return n**2 + 2*n + 2 def g(n): return n**2 - 2*n + 2 T = int(input()) for _ in range(T): n = int(input()) if n == 1 or n == -1: print("Yes") else: print("No") a = f(n) b = g(n) two, five = 0, 0 while a % 2 == 0: two += 1 a //= 2 while a % 5 == 0: five += 1 a //= 5 while b % 2 == 0: two += 1 b //= 2 while b % 5 == 0: five += 1 b //= 5 print(min(two, five))