#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(10);
  int t;
  cin >> t;
  while (t--) {
    int a;
    cin >> a;
    int b = 2, p = 1;
    while (b <= a) {
      b <<= 1;
      p++;
    }
    b--;
    if (a ^ b) {
      cout << b << endl;
    } else {
      int maxv = 1;
      for (int i = 2; i * i <= a; i++)
        if (a % i == 0) {
          maxv = a / i;
          break;
        }
      cout << maxv << endl;
    }
  }
  return 0;
}
