#include <bits/stdc++.h>
using namespace std;
vector<vector<long long> > A, B, C;
bool comp(long long &a, long long &b) { return a > b; }
void solve() {
  long long n;
  cin >> n;
  long long m = 1;
  long long ans = 1;
  if (floor(log2(n + 1)) == ceil(log2(n + 1))) {
    for (long long i = 2; i <= sqrt(n); i++) {
      if (n % i == 0) {
        ans = max(ans, max(i, n / i));
      }
    }
    cout << ans << endl;
    return;
  }
  long long num = floor(log2(n));
  while (num--) {
    ans *= 2;
  }
  long long k = ans * 2;
  k--;
  num = ans;
  while (num) {
    ans += num / 2;
    num /= 2;
  }
  cout << ans << endl;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int test = 1;
  cin >> test;
  while (test--) {
    solve();
  }
}
