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