#include <bits/stdc++.h>
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  std::cerr << name << " : " << arg1 << '\n';
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  std::cerr.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
long long int ans = 0;
long long int power(long long int a, long long int b) {
  if (b == 0) {
    return 1;
  } else if (b % 2 == 0) {
    return power(a * a, b / 2);
  } else {
    return a * power(a * a, (b - 1) / 2);
  }
}
int main() {
  std::ios_base::sync_with_stdio(false);
  long long int t;
  cin >> t;
  long long int cas = 0;
  while (cas < t) {
    long long int a;
    cin >> a;
    double f = log2(a);
    double x = log2(a + 1);
    if (x - (long long int)x == 0) {
      long long int n = a;
      vector<long long int> factors;
      int i = 1;
      while (i <= sqrt(n)) {
        if (n % i == 0) {
          if (i == n / i) {
            factors.push_back(i);
          } else {
            factors.push_back(i);
            factors.push_back(n / i);
          }
        }
        i++;
      }
      sort(factors.begin(), factors.end());
      cout << factors[(long long int)factors.size() - 2] << '\n';
    } else {
      long long int z = (long long int)f;
      z++;
      cout << power(2, z) - 1 << '\n';
    }
    cas++;
  }
  return 0;
}
