#include using namespace std; int x, i, cnt, n, lg; int main() { cin >> n; for (i = 1; i <= n; ++ i) { cin >> x; cnt = 0; lg = 0; while (x > 0) { if (x % 2 == 1) cnt ++; x /= 2; lg ++; } int ans = 0; for (int j = lg - 1; j >= 0 && cnt > 0; -- j, -- cnt) ans += (1 << j); cout << ans << " "; } return 0; }