#include <bits/stdc++.h>
using namespace std;
int mostBitOn(int n) {
  if (n == 0) return 0;
  int msb = 0;
  while (n != 0) {
    n = n / 2;
    msb++;
  }
  return msb;
}
map<int, int> cache;
int main() {
  cache[1] = 0;
  cache[3] = 1;
  cache[7] = 1;
  cache[15] = 5;
  cache[31] = 1;
  cache[63] = 21;
  cache[127] = 1;
  cache[255] = 85;
  cache[511] = 73;
  cache[1023] = 341;
  cache[2047] = 89;
  cache[4095] = 1365;
  cache[8191] = 1;
  cache[16383] = 5461;
  cache[32767] = 4681;
  cache[65535] = 21845;
  cache[131071] = 1;
  cache[262143] = 87381;
  cache[524287] = 1;
  cache[1048575] = 349525;
  cache[2097151] = 299593;
  cache[4194303] = 1398101;
  cache[8388607] = 178481;
  cache[16777215] = 5592405;
  cache[33554431] = 1082401;
  int t, a;
  cin >> t;
  while (t--) {
    cin >> a;
    int msb = mostBitOn(a);
    int opsi1 = 0, opsi2 = 0;
    int b = 0;
    for (int i = 0; i < msb; i++) {
      if (((1 << i) & a) == 0) {
        b += (1 << i);
      }
    }
    if (b > 0)
      opsi1 = (a ^ b);
    else {
      int maxGcd = cache[a];
      opsi2 = maxGcd;
    }
    cout << max(opsi1, opsi2) << endl;
  }
  return 0;
}
