题目大意
分析
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
typedef long long LL;
int t;
LL x;
LL phi(LL n){
LL tmp = n;
for(LL i=2;i*i<=n;i++)
if(n%i == 0){
tmp = tmp/i*(i-1);
while(n%i == 0) n /= i;
}
if(n > 1) tmp = tmp/n*(n-1);
return tmp;
}
LL pwr(LL n,LL k,LL p){
LL ans = 1;
while(k) {if(k&1) ans=(ans*n)%p;n=(n*n)%p;k>>=1;}
return ans;
}
LL f(LL p)
{
if(p==1) return 0;
LL phi_p=phi(p);
return pwr(2,f(phi_p)+phi_p,p);
}
int main(){
scanf("%d",&t);
while( t-- ){
scanf("%lld",&x);
printf("%lld\n",f(x));
}
return 0;
}