#include <bitset>
#include <vector>
#include <iostream>
#include <algorithm>
const int maxn = 100000008;
std::vector<int> prm, pre; // pre is the min-factor array.
bool np[maxn];
void getPrime(const int N = 100000000) {//线性筛!
pre.resize(N + 1);
for (int i = 2; i <= N; ++i) {
if (!np[i]) {
prm.push_back(i); pre[i] = i;
}
for (auto p : prm) if (i * p <= N) {
int k = i * p;
np[k] = true;
pre[k] = p;
if (i % p == 0) break;
} else break;
}
}
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
getPrime();
int T, n;
for (std::cin >> T; T; --T) {
std::cin >> n;
int ans = 0;
while (n != 1) {
ans ^= pre[n];
n /= pre[n];
}
std::cout << ans << '\n';
}
}
okk