#include using namespace std; typedef long long ll; typedef pair P; #define REP(i,n) for(ll i=0;i> T; while(T--){ ll N; cin >> N; if(labs(N)==1){ cout << "Yes" << endl; cout << 0 << endl; continue; } if(N==0){ cout << "No" << endl; cout << 0 << endl; continue; } ll x=N*N+2*N+2,y=N*N-2*N+2; ll c=0,d=0; while(x%2==0){ c++; x/=2; } while(x%5==0){ d++; x/=5; } ll cc=0,dd=0;; while(y%2==0){ cc++; y/=2; } while(y%5==0){ dd++; y/=5; } cout << "No" << endl; cout << min(c+cc,d+dd) << endl; } return 0; }