#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
ll N,x,rs,k,l;
int main(){
    cin >> N;
    while(N--){
        cin >> x;
        k = rs = l = 0;
        while(x) k+=x%2, x/=2, l++;
        while(k) rs+=(1LL<<(l-1)), l--,k--;
        cout<<rs<<' ';
    }
}