#include #include #include #include #include #include #include #include #include #include #define mkp make_pair #define mkt make_tuple #define rep(i,n) for(int i = 0; i < (n); ++i) #define all(v) v.begin(),v.end() using namespace std; typedef long long ll; const ll MOD=1e9+7; template void chmin(T &a,const T &b){if(a>b) a=b;} template void chmax(T &a,const T &b){if(a0){ if(n&1) res=res*a%mod; a=a*a%mod; n>>=1; } return res; } // gcd(a,mod) = 1 ll mod_inv(ll a,ll mod){ ll b=mod,u=1,v=0; while(b){ ll t=a/b; a-=t*b;swap(a,b); u-=t*v;swap(u,v); } u%=mod; if(u<0) u+=mod; return u; } // minimum x for a^x = b (mod) // gcd(a,mod) = 1 // x > 0 [x >= 0] ll mod_log(ll a,ll b,ll mod){ a%=mod;b%=mod; ll low=-1,high=mod; while(abs(high-low)>1){ ll mid=(low+high)/2; if(mid*mid>=mod) high=mid; else low=mid; } //ll sqm=sqrt(mod)+1; ll sqm=high; map apow; ll val=a; for(int r=1;r0) return q*sqm; else if(apow.count(target)){ ll res=sqm*q+apow[target]; if(res>0) return res; //return res; } target=target*A%mod; } return -1; } void solve(){ ll N; cin>>N; ll base=10; if(N%2==0){ while(N%2==0) N/=2; //N/=2; //base/=2; } if(N%5==0){ while(N%5==0) N/=5; //N/=5; //base/=5; } //cout<>T; rep(i,T) solve(); return 0; }