#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const long double PI = 4 * atan((long double)1);
long long power(long long a, long long n) {
  long long res = 1;
  while (n) {
    if (n % 2) res *= a;
    a *= a;
    n /= 2;
  }
  return res;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int q;
  cin >> q;
  vector<long long> v;
  long long int x = 2, y = 2;
  for (int i = 1;; i++) {
    v.push_back(y - 1);
    y = y * x;
    if (y > 1000000001) break;
  }
  for (int i = (0); i < (q); ++i) {
    long long int u;
    cin >> u;
    int ind = lower_bound(v.begin(), v.end(), u) - v.begin();
    if (v[ind] == u) {
      int j = -1;
      for (long long int l = 2; l * l <= u; l++) {
        if (u % l == 0) {
          j = l;
          break;
        }
      }
      if (j == -1)
        cout << 1;
      else
        cout << u / j;
    } else
      cout << v[ind];
    cout << "\n";
  }
  return 0;
}
