#include using namespace std; using i64 = long long; int main() { cin.tie(nullptr)->sync_with_stdio(false); auto solve = [&]() { i64 n; cin >> n; n = abs(n); // (n^2 + 2n + 2) (n^2 - 2n + 2) if (n == 1) { cout << "Yes" << '\n'; } else { cout << "No" << '\n'; } auto get = [&](i64 n) { array res{}; while (n % 10 == 0) { n /= 10; res[0]++; } while (n % 2 == 0) { n /= 2; res[1]++; } while (n % 5 == 0) { n /= 5; res[2]++; } return res; }; auto [x10, x2, x5] = get(n * n + 2 * n + 2); auto [y10, y2, y5] = get(n * n - 2 * n + 2); int ans = x10 + y10 + min(x2 + y2, x5 + y5); cout << ans << '\n'; }; int t; cin >> t; while (t--) { solve(); } return 0; }