#include <bits/stdc++.h>
using namespace std;
const double pi = 2 * acos(0.0);
const int oo = 0x3f3f3f3f;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int q;
  cin >> q;
  vector<int> predp = {
      1,      1,      5,       1,      21,      1,       85,       73,      341,
      89,     1365,   1,       5461,   4681,    21845,   1,        87381,   1,
      349525, 299593, 1398101, 178481, 5592405, 1082401, 22369621, 19173961};
  for (int i = 0; i < q; ++i) {
    int a;
    cin >> a;
    bool f = false;
    int w = 1;
    for (; w <= a; w <<= 1, w += 1) {
      if (a == w) {
        f = true;
        break;
      }
    }
    if (f) {
      cout << predp[__builtin_popcountl(a) - 2] << endl;
    } else {
      cout << w << endl;
    }
  }
}
