#include<cmath> #include<algorithm> using namespace std; int solve(long long a, int flag) { if(a <= 3) { if(a == 3) return abs(1 - flag); else return abs(0 - flag); } else { //printf("a %lld\n", a); int i = 0; long long p = a; while(p != 1){ p /= 2; i++; } long long now = 1; while(i--) now *= 2; if(now == a) return abs(0-flag); flag = abs(1 - flag); return solve(2 * now - a,flag); } } int main() { int t; scanf("%d", &t); while(t--) { long long a; scanf("%lld", &a); printf("%d\n", solve(a,0)); } return 0; }