#include <bits/stdc++.h>
using namespace std;
int jaw[40];
int gcd(int a, int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
int main() {
  jaw[2] = 1;
  jaw[3] = 1;
  jaw[4] = 5;
  jaw[5] = 1;
  jaw[6] = 21;
  jaw[7] = 1;
  jaw[8] = 85;
  jaw[9] = 73;
  jaw[10] = 341;
  jaw[11] = 89;
  jaw[12] = 1365;
  jaw[13] = 1;
  jaw[14] = 5461;
  jaw[15] = 4681;
  jaw[16] = 21845;
  jaw[17] = 1;
  jaw[18] = 87381;
  jaw[19] = 1;
  jaw[20] = 349525;
  jaw[21] = 299593;
  jaw[22] = 1398101;
  jaw[23] = 178481;
  jaw[24] = 5592405;
  jaw[25] = 1082401;
  int q;
  cin >> q;
  for (int i = 1; i <= q; i++) {
    int a;
    cin >> a;
    for (int j = 2; j <= 25; j++) {
      int now = (1 << j) - 1;
      if (a < now) {
        cout << now << "\n";
        break;
      } else if (a == now) {
        cout << jaw[j] << "\n";
        break;
      }
    }
  }
}
