#include <iostream>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
#define mst(a,b) memset(a,b,sizeof(a))
#define REP(a,b,c) for(int a = b; a < c; ++a)
#define eps 10e-8
const int MAX_ = 10010;
const int N = 100010;
const int INF = 0x7fffffff;
const int M = 1000000007;
long long reverse2(const long long n) {
long long sum = 0, tmp = 0, m;
m = n;
while(m) {m>>=1;tmp++;}
m = n;
sum = 0;
while(tmp--) {
sum <<= 1;
sum += m&1;
m>>=1;
}
return sum;
}
int main() {
int T;
long long n;
cin>>T;
REP(Ca,1,T+1) {
cin>>n;
cout<<reverse2(n)<<endl;
}
return 0;
}