#include <bits/stdc++.h>
using namespace std;
int a[] = {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 sol(int x) {
  int s = 1;
  for (int i = (2); i <= (25); ++i) {
    s = s * 2 + 1;
    if (x == s) return a[i];
    if (x < s) return s;
  }
  return s;
}
int main() {
  int q;
  scanf("%d", &q);
  while (q--) {
    int x;
    scanf("%d", &x);
    printf("%d\n", sol(x));
  }
}
