#include <bits/stdc++.h>
using namespace std;
int jud(int a) {
  a++;
  while (a % 2 == 0) a /= 2;
  return a == 1;
}
int jud1(int a) {
  a++;
  while (a % 4 == 0) a /= 4;
  return a == 1;
}
int f(int a) {
  int cnt = 1;
  while (a /= 2) cnt *= 2;
  return 2 * cnt - 1;
}
int gcd(int a, int b) {
  if (b == 0) return a;
  if (a == 0) return b;
  if (a % b == 0) return b;
  return gcd(b, a % b);
}
int findm(int a) {
  int m = 0;
  for (int i = 1; i < a; i++) m = max(m, gcd(a ^ i, a & i));
  return m;
}
int gao(int a) {
  if (!jud(a))
    return f(a);
  else if (a > 3) {
    for (int i = 2; i * i <= a; i++) {
      if (a % i == 0) return a / i;
    }
    return 1;
  } else
    return 1;
}
int main() {
  long long a;
  int t;
  cin >> t;
  while (t--) {
    cin >> a;
    cout << gao(a) << endl;
  }
}
