#include <bits/stdc++.h>
using namespace std;
long long answer[100] = {0,      1,       1,      1,       5,      1,    21,
                         1,      85,      73,     341,     89,     1365, 1,
                         5461,   4681,    21845,  1,       87381,  1,    349525,
                         299593, 1398101, 178481, 5592405, 1082401};
long long cnt(long long x) {
  int res = 0;
  for (; x; x >>= 1)
    if (x & 1) res++;
  return res;
}
int main() {
  int T;
  scanf("%d", &T);
  while (T--) {
    long long x, ans = 1;
    scanf("%lld", &x);
    while (ans <= x) ans <<= 1;
    if (ans - 1 != x)
      printf("%lld\n", ans - 1);
    else
      printf("%lld\n", answer[cnt(ans - 1)]);
  }
  return 0;
}
