// verification-helper: PROBLEM https://yukicoder.me/problems/4474 #include using namespace std; #define call_from_test #ifndef call_from_test #include using namespace std; #endif //BEGIN CUT HERE template T mod_pow(T a,long long n,T mod){ using ll = long long; T res(1); while(n){ if(n&1) res=(ll)res*a%mod; a=(ll)a*a%mod; n>>=1; } return res; } //END CUT HERE #ifndef call_from_test //INSERT ABOVE HERE signed main(){ return 0; } #endif #ifndef call_from_test #include using namespace std; #define call_from_test #include "pow.cpp" #undef call_from_test #endif //BEGIN CUT HERE template T order(T x,T MOD){ static map> dp; static map phi; vector &ps=dp[MOD]; if(ps.empty()){ T res=MOD,n=MOD; for(T i=2;i*i<=n;i++){ if(n%i!=0) continue; ps.emplace_back(i); res=res/i*(i-1); while(n%i==0) n/=i; } if(n!=1){ ps.emplace_back(n); res=res/n*(n-1); } phi[MOD]=res; } T res=phi[MOD]; for(T p:ps){ while(res%p==0){ if(mod_pow(x,res/p,MOD)!=1) break; res/=p; } } return res; } //END CUT HERE #ifndef call_from_test //INSERT ABOVE HERE signed main(){ return 0; } #endif #undef call_from_test signed main(){ cin.tie(0); ios::sync_with_stdio(0); const char newl = '\n'; int T; cin>>T; while(T--){ long long n; cin>>n; cout<