#include using namespace std; long long i, n, x, j; vector v; int main() { ios_base::sync_with_stdio(0); cin >> n; for(i = 1; i <= n; ++i) { cin >> x; v.clear(); while(x) v.push_back(x % 2), x /= 2; sort(v.begin(), v.end()); reverse(v.begin(), v.end()); for(auto it : v) x *= 2, x += it; cout << x << ' '; } return 0; }