#include <bits/stdc++.h>
using namespace std;
const long long MAXN = 1e6 + 5;
const long long mod = 1e9 + 7;
bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) {
  return (a.second < b.second);
}
long long powermod(long long x, long long y, long long p) {
  long long res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
bool isprime(int n) {
  if (n <= 1) return false;
  if (n <= 3) return true;
  if (n % 2 == 0 || n % 3 == 0) return false;
  for (int i = 5; i * i <= n; i = i + 6)
    if (n % i == 0 || n % (i + 2) == 0) return false;
  return true;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long t;
  cin >> t;
loop:
  while (t--) {
    long long n;
    cin >> n;
    for (long long i = 0; i < 26; i++) {
      long long x = 1 << i;
      if (x - 1 == n) {
        long long ans = 1;
        for (long long j = 2; j * j <= n; j++) {
          if (n % j == 0) {
            ans = n / j;
            break;
          }
        }
        cout << ans << "\n";
        goto loop;
      } else if (x - 1 > n) {
        cout << x - 1 << "\n";
        goto loop;
      }
    }
  }
  return 0;
}
