#include <bits/stdc++.h>
using namespace std;
long long n, m, k, ans;
int main() {
  long long i, j, x, y;
  long long TC;
  scanf("%lld", &TC);
  while (TC--) {
    scanf("%lld", &x);
    y = 2;
    while (y <= x) y *= 2;
    y--;
    if (x == y) {
      y = sqrt(x);
      j = 1;
      for (i = y; i >= 2; i--) {
        if (x % i == 0) {
          j = max(j, max(i, x / i));
        }
      }
      printf("%lld\n", (j == 1) ? 1LL : j);
    } else {
      printf("%lld\n", y);
    }
  }
  return 0;
}
