#include <bits/stdc++.h>

using namespace std;

inline void debugMode() {
    #ifndef ONLINE_JUDGE
    freopen("debug.in", "r", stdin);
    #endif // ONLINE_JUDGE
}



int main()
{
    ios :: sync_with_stdio(false);
    debugMode();

    long long n,x,k,kk;

    cin >> n;

    for(int i = 1; i <= n; i++){
        k = -1;
        kk = 0;

        cin >> x;

        while(x != 0){
            k++;
            if(x % 2 == 1)
                kk++;
            x /=2;
        }
        x = 0;
        for(;kk > 0;kk--,k--)
            x = x + (1 << k);

        cout << x << " ";

    }

    return 0;
}