#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.precision(0);
  map<int, int> precompute = {{1, 0},
                              {3, 1},
                              {7, 1},
                              {15, 5},
                              {31, 1},
                              {63, 21},
                              {127, 1},
                              {255, 85},
                              {511, 73},
                              {1023, 341},
                              {2047, 89},
                              {4095, 1365},
                              {8191, 1},
                              {16383, 5461},
                              {32767, 4681},
                              {65535, 21845},
                              {131071, 1},
                              {262143, 87381},
                              {524287, 1},
                              {1048575, 349525},
                              {1048575, 349525},
                              {2097151, 299593},
                              {4194303, 1398101},
                              {8388607, 178481},
                              {16777215, 5592405},
                              {33554431, 1082401}};
  int q;
  cin >> q;
  while (q--) {
    int x;
    cin >> x;
    if (precompute.find(x) != precompute.end()) {
      cout << precompute[x] << endl;
    } else {
      cout << (1 << (8 * sizeof(int) - __builtin_clz(x))) - 1 << endl;
    }
  }
  return 0;
}
