#include <cstdio>
#include <unordered_map>
using namespace std;
const int N = 5000000;
int prime[N + 5], min_prime[N + 5], cnt = 0;
long long pre_miu[N + 5], pre_phi[N + 5];
unordered_map<int, long long> mry_pre_miu, mry_pre_phi;
inline void Primes(int n) {
pre_miu[1] = 1, pre_phi[1] = 1;
for (int i = 2; i <= n; i++) {
if (min_prime[i] == 0) {
min_prime[i] = i;
prime[++cnt] = i;
pre_miu[i] = -1, pre_phi[i] = i - 1;
}
for (int j = 1; j <= cnt; j++) {
if (prime[j] > min_prime[i] || i * prime[j] > n)break;
min_prime[i * prime[j]] = prime[j];
if (i % prime[j] == 0) {
pre_miu[i * prime[j]] = 0;
pre_phi[i * prime[j]] = pre_phi[i] * prime[j];
} else {
pre_miu[i * prime[j]] = -pre_miu[i];
pre_phi[i * prime[j]] = pre_phi[i] * (prime[j] - 1);
}
}
}
for (int i = 1; i <= n; i++) {
pre_miu[i] = pre_miu[i - 1] + pre_miu[i];
pre_phi[i] = pre_phi[i - 1] + pre_phi[i];
}
}
long long Pre_Miu(int n) {
if (n <= N)return pre_miu[n];
if (mry_pre_miu[n] != 0)return mry_pre_miu[n];
long long ans = 1;
for (int l = 2, r; l <= n; l = r + 1) {
r = n / (n / l);
ans -= Pre_Miu(n / l) * (r - l + 1);
}
mry_pre_miu[n] = ans;
return ans;
}
long long Pre_Phi(int n) {
if (n <= N)return pre_phi[n];
if (mry_pre_phi[n] != 0)return mry_pre_phi[n];
long long ans = (long long) n * (n + 1) / 2;
for (int l = 2, r; l <= n; l = r + 1) {
r = n / (n / l);
ans -= Pre_Phi(n / l) * (r - l + 1);
}
mry_pre_phi[n] = ans;
return ans;
}
signed main() {
Primes(N);
int ts;
scanf("%d", &ts);
while (ts--) {
int n;
scanf("%d", &n);
printf("%lld %lld\n", Pre_Phi(n), Pre_Miu(n));
}
return 0;
}