#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10;
const int inf = 2147483647;
const long double pi = acos(-1);
inline unsigned long long read() {
  unsigned long long data = 0, w = 1;
  char ch = getchar();
  while (ch != '-' && (ch < '0' || ch > '9')) ch = getchar();
  if (ch == '-') w = -1, ch = getchar();
  while (ch <= '9' && ch >= '0') data = data * 10 + ch - 48, ch = getchar();
  return data * w;
}
inline void file() {
  freopen(
      "a"
      ".in",
      "r", stdin);
  freopen(
      "a"
      ".out",
      "w", stdout);
}
int n;
inline int check(unsigned long long x) {
  int mx = 1;
  for (int i = 2; 1ll * i * i <= x; i++)
    if (x % i == 0)
      mx = max((unsigned long long)mx, max((unsigned long long)i, x / i));
  return mx;
}
int main() {
  n = read();
  for (int i = 1; i <= n; i++) {
    unsigned long long x = read(), r = x;
    int cnt = 0;
    while (r) {
      cnt++;
      r >>= 1;
    }
    if (x == (1ll << cnt) - 1)
      printf("%d\n", check(x));
    else
      printf("%I64d\n", (1ll << cnt) - 1);
  }
  return 0;
}
