#include <bits/stdc++.h>
using namespace std;
map<int, int> g;
int main() {
  int q;
  g[1] = 1;
  g[3] = 1;
  g[7] = 1;
  g[15] = 5;
  g[31] = 1;
  g[63] = 21;
  g[127] = 1;
  g[255] = 85;
  g[511] = 73;
  g[1023] = 341;
  g[2047] = 89;
  g[4095] = 1365;
  g[8191] = 1;
  g[16383] = 5461;
  g[32767] = 4681;
  g[65535] = 21845;
  g[131071] = 1;
  g[262143] = 87381;
  g[524287] = 1;
  g[1048575] = 349525;
  g[2097151] = 299593;
  g[4194303] = 1398101;
  g[8388607] = 178481;
  g[16777215] = 5592405;
  g[33554431] = 1082401;
  cin >> q;
  for (int t = 0, a; t < q; t++) {
    cin >> a;
    int x = 1;
    while (x <= a) x <<= 1;
    x--;
    if (x == a) x = g[x];
    cout << x << '\n';
  }
  return 0;
}
