1 /*
2 宋代朱敦儒
3 《西江月·世事短如春梦》
4 世事短如春梦,人情薄似秋云。不须计较苦劳心。万事原来有命。
5 幸遇三杯酒好,况逢一朵花新。片时欢笑且相亲。明日阴晴未定。
6 */
7 #include <cstdio>
8 #include <cstring>
9 #include <algorithm>
10 #include <cmath>
11 #include <queue>
12 #include <vector>
13 #include <iostream>
14 #include <string>
15 #include <ctime>
16 #define LOCAL
17 const int MAXN = 10000000 + 10;
18 const long long MOD = 1000000007;
19 const double Pi = acos(-1.0);
20 long long G = 15;//原根
21 const int MAXM = 60 * 2 + 10;
22 using namespace std;
23 typedef long long ll;
24 int phi[MAXN], prime[MAXN];
25
26 void read(int &x){//读入优化
27 char ch;x = 0;
28 int flag = 1;
29 ch = getchar();
30 while (ch < ‘0‘ || ch > ‘9‘) {if (ch == ‘0‘) flag = -1; ch = getchar();}
31 while (ch >= ‘0‘ && ch <= ‘9‘) {x = x * 10 + (ch - ‘0‘); ch = getchar();}
32 x *= flag;
33 }
34
35 void prepare(){//预处理phi函数
36 memset(prime, 0, sizeof(prime));
37 for (int i = 2; i <= 10000000; i++){
38 if (!prime[i]){
39 prime[++prime[0]] = i;
40 phi[i] = i - 1;
41 //printf("%d\n", prime[prime[0]]);
42 }
43 for (int j = 1; j <= prime[0]; j++){
44 if ((long long)i * (long long)prime[j] > 10000000ll) break;
45 prime[i * prime[j]] = 1;
46 if (i % prime[j] == 0){
47 phi[i * prime[j]] = phi[i] * prime[j];
48 break;
49 }else{
50 phi[i * prime[j]] = phi[i] * (prime[j] - 1);
51 }
52 }
53 }
54 }
55 ll pow(ll a, ll b, ll c){
56 if (b == 0) return 1 % c;
57 if (b == 1) return a % c;
58 ll tmp = pow(a, b / 2, c);
59 if (b % 2 == 0) return (tmp * tmp) % c;
60 else return (((tmp * tmp) % c) * (a % c)) % c;
61 }
62 ll work(ll n){
63 if (n == 1ll) return 0;
64 return pow(2ll, ((ll)work((ll)phi[n]) + (ll)phi[n]), n);
65 }
66
67 int main(){
68 int T;
69
70 prepare();
71 scanf("%d", &T);
72 while (T--){
73 ll n;
74 scanf("%lld", &n);
75 printf("%lld\n", work(n));
76 }
77 return 0;
78 }