#include <bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define endl '\n'
#define Endl '\n'
using namespace std;
const int N = 2e5 + 5;
int tc, n, m, a[N];
random_device rd;
mt19937 eng(rd());
ll computeXOR(ll n) {
if (n % 4 == 0)
return n;
if (n % 4 == 1)
return 1;
if (n % 4 == 2)
return n + 1;
return 0;
}
int getRandomNumberInRange(int min, int max) {
uniform_int_distribution<> distribution(min, max);
return distribution(eng);
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0); // cout.tie(0);
cin >> tc;
while (tc--) {
cin >> n;
cout << computeXOR(n) << endl;
}
return 0;
}