#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#define ull unsigned long long
using namespace std;
string gen(ull);
string inv(string);
int main(void)
{
int n;
cin >> n;
vector<int> ks;
int max = 0;
int k;
for (int i = 0; i < n; i++)
{
cin >> k;
ks.push_back(k);
if (k > max) max = k;
}
for (int i = 0; i < n; i++)
{
cout << s[ks[i]-1] << '\n';
}
}
string gen(ull k_max)
{
int n = ceil(log(float(k_max))/log(2.0)+1);
string s = "0";
for (int i = 1; i < n; i++)
{
s+=inv(s);
}
return s;
}
string inv(string s)
{
for (int i = 0, l = s.length(); i < l; i++)
{
if (s[i] == '1') s[i] = '0';
else s[i] = '1';
}
return s;
}