#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
inline int read() {
  int X = 0, w = 0;
  char ch = 0;
  while (!isdigit(ch)) {
    w |= ch == '-';
    ch = getchar();
  }
  while (isdigit(ch)) X = (X << 3) + (X << 1) + (ch ^ 48), ch = getchar();
  return w ? -X : X;
}
int a[30];
int main() {
  for (int i = 0; i <= 24; i++) {
    int x = (1 << (i + 1)) - 1;
    a[i] = 1;
    for (int j = 2; j * j <= x; j++) {
      if (x % j == 0) {
        a[i] = x / j;
        break;
      }
    }
  }
  int T;
  cin >> T;
  while (T--) {
    int n;
    cin >> n;
    int upbit = 2;
    for (int i = 25; i >= 0; i--) {
      if ((1 << i) & n) {
        upbit = i;
        break;
      }
    }
    if ((1 << (upbit + 1)) - 1 != n) {
      cout << (1 << (upbit + 1)) - 1 << endl;
    } else {
      cout << a[upbit] << endl;
    }
  }
  return 0;
}
