#include <bits/stdc++.h>
using namespace std;
long long aa, a;
long long run(long long temp) {
  for (int i = 2; i * i <= temp; i++) {
    if (temp % i == 0) {
      return temp / i;
    }
  }
  return 1;
}
void solve() {
  cin >> a;
  aa = a;
  long long cnt = 0;
  bool flag = 0;
  while (aa) {
    cnt++;
    if (aa % 2 == 0) {
      flag = 1;
    }
    aa >>= 1;
  }
  if (!flag) {
    if (cnt & 1) {
      cout << run(a) << "\n";
    } else {
      cout << (a) / 3 << "\n";
    }
  } else {
    cout << ((1 << (cnt)) - 1) << "\n";
  }
}
int main() {
  ios::sync_with_stdio(false);
  int Case;
  cin >> Case;
  while (Case--) {
    solve();
  }
}
