#include <bits/stdc++.h>
int tsts;
template <typename __T>
__T __gcd(__T __m, __T __n) {
  while (__n != 0) {
    __T __t = __m % __n;
    __m = __n;
    __n = __t;
  }
  return __m;
}
using namespace std;
const int N = 120, M = N * N + N;
int n;
const int ans[] = {1,      1,      5,       1,      21,      1,
                   85,     73,     341,     89,     1365,    1,
                   5461,   4681,   21845,   1,      87381,   1,
                   349525, 299593, 1398101, 178481, 5592405, 1082401};
int main() {
  scanf("%d", &tsts);
  while (tsts--) {
    scanf("%d", &n);
    int i;
    int xx = 30;
    for (i = 1 << 30; i > 0; i >>= 1) {
      --xx;
      if (n & i) break;
    }
    i = (i << 1) - 1;
    if (~n & i)
      printf("  %d\n", i);
    else {
      printf("  %d\n", ans[xx]);
    }
  }
}
