#include <bits/stdc++.h>
using namespace std;
int table[26] = {0,      0,       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 get(int a) {
  if (__builtin_popcount(a + 1) == 1) {
    return table[__builtin_popcount(a)];
  } else {
    return (1 << (32 - __builtin_clz(a))) - 1;
  }
}
int main() {
  int q, a;
  scanf("%d", &q);
  while (q--) {
    scanf("%d", &a);
    printf("%d\n", get(a));
  }
}
