#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
vector<long long> v;
unordered_map<long long, long long> m;
long long falla(long long n) {
  if (m.count(n)) {
    return m[n];
  }
  long long ans;
  long long k = 0;
  for (int j = n - 1; j >= 1; j--) {
    if (n % j == 0) {
      ans = j;
      break;
    }
    if (n % (n - j + 1) == 0) {
      ans = n / (n - j + 1);
      break;
    }
  }
  m[ans] = ans;
  return ans;
}
int main() {
  long long casos;
  cin >> casos;
  long long num = pow(2, 25) - 1;
  for (int i = 1; i < 30; i++) {
    v.push_back((1 << i) - 1);
  }
  long long flag = 0;
  while (casos--) {
    long long num;
    long long ans1;
    cin >> num;
    if (m.count(num)) {
      cout << m[num] << endl;
      flag = 1;
    }
    if (flag == 0) {
      ans1 = lower_bound((v).begin(), (v).end(), num) - v.begin();
      if (num == v[ans1]) {
        ans1 = falla(num);
        m[num] = ans1;
        cout << ans1 << endl;
      } else {
        m[num] = v[ans1];
        cout << v[ans1] << endl;
      }
    }
    flag = 0;
  }
}
