#include<bits/stdc++.h>
using namespace std;
using ll = long long;
ll t,n,m,k,l,r,op,x,y;
vector<ll> vec;
void solve(){
cin>>t;
while(t--){
vec.clear();
cin>>n;
do{
vec.push_back(n&1);
n>>=1;
}while(n);
while(vec.size()!=32)vec.push_back(0);
ll ans = 0;
for(int i = 0;i<32;i++){
ans += pow(2,32-i-1) * vec[i];
}
cout<<ans<<"\n";
}
}
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
solve();
return 0;
}