T = int(input()) for _ in range(T): N = int(input()) print('Yes' if abs(N) == 1 else 'No') a = (N - 1)**2 + 1 b = (N + 1)**2 + 1 res = 0 while a % 10 == 0: a //= 10 res += 1 while b % 10 == 0: b //= 10 res += 1 c = a * b while c % 10 == 0: c //= 10 res += 1 print(res)