#include <iostream>
#include <vector>
std::vector<int> bits;
void ToBinary(int n)
{
if (n / 2 != 0) {
ToBinary(n / 2);
}
bits.push_back(n % 2);
}
int main()
{
std::vector<int> answers;
long long input;
std::cin >> input;
long long bitPlace;
for (int i = 0; i < input; i++)
{
bits.clear();
std::cin >> bitPlace;
ToBinary(bitPlace - 1);
int countOnes = std::count(bits.begin(), bits.end(), 1);
if (countOnes % 2) answers.push_back(1);
else answers.push_back(0);
}
for (unsigned int i = 0; i < answers.size(); i++)
{
std::cout << answers[i] << '\n';
}
return 0;
}