#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main()
{
int n;
while(cin >> n)
{
for(int i = 0; i < n; i ++)
{
int x;
cin >> x;
if(!(x&1))
{
for(int i = 31; i >= 0; i --)
{
if((x>>i)&1)//从左往右找到第一个1
{
int ans = 0;
for(int j = i, k = 0; j >= 0; j --, k++)//x从左往右,ans从右往左
{
if((x>>j)&1)
ans |= 1<<k;
else
ans &= ~(1<<k);
}
x = ans;
break;
}
}
}
printf("%d%c", x, i == n-1 ? '\n' : ' ');
}
}
return 0;
}