#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e6 + 1;
int sfac[N];
int EP(int m) {
int res = m, cur = m;
while (cur > 1) {
int pf = sfac[cur];
res -= res / pf;
while (cur % pf == 0)
cur /= pf;
}
return res;
}
int main(int argc, char **argv) {
for (int p = 0; p < N; ++p)
sfac[p] = p;
for (int p = 2; p * p < N; ++p)
if (sfac[p] == p)
for (int q = p * p; q < N; q += p)
sfac[q] = min(sfac[q], p);
int T;
scanf("%d", &T);
while (T-- != 0) {
int m;
scanf("%d", &m);
int a = EP(m);
int b = m - 1;
printf("%lld\n", 1LL * a * b);
}
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7Cgp0eXBlZGVmIGxvbmcgbG9uZyBsbDsKCmNvbnN0IGludCBOID0gMWU2ICsgMTsKaW50IHNmYWNbTl07CgppbnQgRVAoaW50IG0pIHsKCWludCByZXMgPSBtLCBjdXIgPSBtOwoJd2hpbGUgKGN1ciA+IDEpIHsKCQlpbnQgcGYgPSBzZmFjW2N1cl07CgkJcmVzIC09IHJlcyAvIHBmOwoJCXdoaWxlIChjdXIgJSBwZiA9PSAwKQoJCQljdXIgLz0gcGY7Cgl9CglyZXR1cm4gcmVzOwp9CgppbnQgbWFpbihpbnQgYXJnYywgY2hhciAqKmFyZ3YpIHsKCWZvciAoaW50IHAgPSAwOyBwIDwgTjsgKytwKQoJCXNmYWNbcF0gPSBwOwoJZm9yIChpbnQgcCA9IDI7IHAgKiBwIDwgTjsgKytwKQoJCWlmIChzZmFjW3BdID09IHApCgkJCWZvciAoaW50IHEgPSBwICogcDsgcSA8IE47IHEgKz0gcCkKCQkJCXNmYWNbcV0gPSBtaW4oc2ZhY1txXSwgcCk7CglpbnQgVDsKCXNjYW5mKCIlZCIsICZUKTsKCXdoaWxlIChULS0gIT0gMCkgewoJCWludCBtOwoJCXNjYW5mKCIlZCIsICZtKTsKCQlpbnQgYSA9IEVQKG0pOwoJCWludCBiID0gbSAtIDE7CgkJcHJpbnRmKCIlbGxkXG4iLCAxTEwgKiBhICogYik7Cgl9CglyZXR1cm4gMDsKfQ==