#include <bits/stdc++.h>
using namespace std;
int q, n, f[30];
int main() {
  for (int i = 1; i <= 25; i++) f[i] = f[i - 1] * 2 + 1;
  scanf("%d", &q);
  while (q--) {
    scanf("%d", &n);
    int k = lower_bound(f + 1, f + 25 + 1, n) - f;
    if (f[k] > n) {
      printf("%d\n", f[k]);
      continue;
    }
    int x = n;
    for (int i = 2; i * i <= n; i++)
      if (n % i == 0) {
        x = i;
        break;
      }
    printf("%d\n", n / x);
  }
  return 0;
}
