#include <bits/stdc++.h>
using namespace std;
#define ll long long
class number_theory {
public:
ll gcd(ll x, ll y) {
if (x == 0) return y;
if (y == 0) return x;
return gcd(y, x % y);
}
bool isprime(ll n) {
if (n <= 1) return false;
if (n <= 3) return true;
if (n % 2 == 0 || n % 3 == 0) return false;
for (ll i = 5; i * i <= n; i += 6)
if (n % i == 0 || n % (i+2) == 0)
return false;
return true;
}
bool prime[15000105];
void sieve(int n) {
for (ll i = 0; i <= n; i++) prime[i] = 1;
for (ll p = 2; p * p <= n; p++) {
if (prime[p] == true) {
for (ll i = p * p; i <= n; i += p)
prime[i] = false;
}
}
prime[1] = prime[0] = 0;
}
vector<ll> primelist;
bool __primes_generated__ = 0;
void genprimes(int n) {
__primes_generated__ = 1;
sieve(n + 1);
for (ll i = 2; i <= n; i++) if (prime[i]) primelist.push_back(i);
}
vector<ll> factorss(ll n) {
if (!__primes_generated__) {
cout << "Call genprimes you dope" << endl;
exit(1);
}
vector<ll> facs;
for (ll i = 0; primelist[i] * primelist[i] <= n && i < primelist.size(); i++) {
if (n % primelist[i] == 0) {
while (n % primelist[i] == 0) {
n /= primelist[i];
facs.push_back(primelist[i]);
}
}
}
if (n > 1) {
facs.push_back(n);
}
sort(facs.begin(), facs.end());
return facs;
}
/*
vector<ll> getdivs(ll n) {
vector<ll> divs;
for (ll i = 1; i * i <= n; i++) {
if (n % i == 0) {
divs.push_back(i);
divs.push_back(n / i);
}
}
getunique(divs);
return divs;
}*/
};
void solveMAXGCD(){
int t, n;
cin>>t;
while(t--){
cin>>n;
if(n%2==0) cout<<n/2<<"\n";
else cout<<(n-1)/2<<"\n";
}
}
void solveGCDLCM(){
int t, n;
cin>>t;
while(t--){
cin>>n;
cout<<1<<" "<<n-1<<"\n";
}
}
void solveCat(){
int t; cin>>t;
ll n,k;
while(t--){
cin>>n>>k;
k--;
if(n%2==0){
cout<<1+(k%n)<<"\n";
}
else{
ll inter=k/((n-1)/2);
//no of spces it goes forward
cout<<1+(k+inter)%n<<"\n";
}
}
}
void solveNew(){
ll n;
cin>>n;
set<ll> ans;
for(int i=1;i*i<=n;i++){
if(n%i==0){
ans.insert(((n/i)*(n/i-1)*i*0.5)+n/i);
ans.insert(((n/i)*(i-1)*i*0.5)+(i));
}
}
for(auto it:ans) cout<<it<<" ";
}
void solveMath(){
number_theory obj;
ll n; cin>>n;
obj.genprimes(n);
vector<ll> x=obj.factorss(n);
map<ll,ll> cnt;
for (ll it:x) cnt[it]++;
ll worst=0;
for(pair<ll,ll> x:cnt){
worst=max(worst, x.second);
}
ll b=0;
while(1<<b < worst){
b++;
}
ll ops=b;
bool all_same=1;
for(pair<ll,ll> x:cnt){
if(x.second!=(1<<b)){
all_same=0;
break;
}
}
//cout<<worst<<" ";
if(!all_same) ++ops;
ll p=1;
for(pair<ll,ll> x:cnt ){
p*=x.first;
}
cout<<p<<" "<<ops<<"\n";
}
void solveMeaningLess(){
ll q; ll a; cin>>q;
while(q--){
cin>>a;
ll msb=63-__builtin_clz(a);
ll power_of_two_minus_one=(1<<(msb+1))-1;
if(a!=power_of_two_minus_one){
cout<<power_of_two_minus_one<<"\n";
}
else{
ll best=1;
for(int i=2;i*i<=a;i++){
if(a%i==0){
best=max(best,a/i);
}
}
cout<<best<<"\n";
// a xor b=b-a iff
// gcd(a,b-a)=a if b is a factor of a
}
}
}
int main() {
solveMeaningLess();
return 0;
}