#include <bits/stdc++.h>
using namespace std;
const int Z = (int)1e5 + 111;
const int inf = (int)1e8 + 111;
const long long llinf = (long long)1e18 + 111;
const long double pi = acos(-1.0);
const int delta[2][4] = {{1, -1, 0, 0}, {0, 0, -1, 1}};
const long long MOD = 998244353;
int q;
int main() {
  cin >> q;
  while (q--) {
    bool flag = 0;
    long long a, cnt = 0;
    cin >> a;
    cnt = log2(a) + 1;
    if ((1 << cnt) - 1 != a) {
      cout << (1 << cnt) - 1 << "\n";
    } else {
      for (long long i = 2; i * i <= a; i++) {
        if (!(a % i)) {
          cout << a / i << "\n";
          flag = 1;
          break;
        }
      }
      if (!flag) {
        cout << 1 << "\n";
      }
    }
  }
}
