for _ in range(int(input())): n = abs(int(input())); x = n**4+4; c = 0 while x%10==0: x //= 10; c += 1 print("Yes" if n==1 else "No"); print(c)