#include <fstream>
#include <cmath>
using namespace std;
int doi(long long n)
{ 
	char a[100000]; 
    for (int i=1;i>0;i++)
    {
    	a[i]=n%2;
    	n=n/2;
    }
    return a[10000];
}
 
int main() 
{ 
	ifstream f("doinp.inp");
	ofstream g("doinp.out");
    long long m,a[10000],dem=0; 
	int j;
    f>>m;
    for (j=1;j<=m;j++)
    {f>>a[j];}
    for (j=1;j<=m;j++)
	{g<<doi(a[j])<<endl;
} 
}
	
 

