#include
#include <bits/stdc++.h>
using namespace std;
int main() {
// your code here
int t;
cin>>t;
while(t--)
{
int n;
cin>>n;
if(n%2==1) cout<<n<<endl;
else
{
int k=0,l=0,no=0;
while(n!=0)
{
int f=n%2;
n/=2;
//k=k+f*pow(2,l);
//l++;
no=no*10+f;
}
//cout<<no<<endl;
while(no!=0)
{
int p=no%10;
no/=10;
k=k+p*pow(2,l);
l++;
}
cout<<k<<endl;
}
}
return 0;
}