#include <bits/stdc++.h>
using namespace std;
const long long N = 1e5;
long long id = 0;
map<int, int> ans;
int main() {
  ans[0] = 0;
  ans[1] = 0;
  ans[3] = 1;
  ans[7] = 1;
  ans[15] = 5;
  ans[31] = 1;
  ans[63] = 21;
  ans[127] = 1;
  ans[255] = 85;
  ans[511] = 73;
  ans[1023] = 341;
  ans[2047] = 89;
  ans[4095] = 1365;
  ans[8191] = 1;
  ans[16383] = 5461;
  ans[32767] = 4681;
  ans[65535] = 21845;
  ans[131071] = 1;
  ans[262143] = 87381;
  ans[524287] = 1;
  ans[1048575] = 349525;
  ans[2097151] = 299593;
  ans[4194303] = 1398101;
  ans[8388607] = 178481;
  ans[16777215] = 5592405;
  ans[33554431] = 1082401;
  ans[67108863] = 22369621;
  ios_base::sync_with_stdio(0);
  cout.tie(0);
  cin.tie(0);
  ;
  int q;
  cin >> q;
  for (int i = 0; i < q; ++i) {
    int tmp;
    cin >> tmp;
    if (ans.find(tmp) == ans.end()) {
      long long ret = 0;
      id = 0;
      while (tmp) {
        ret += (1 << id);
        id++;
        tmp >>= 1;
      }
      cout << ret << "\n";
    } else {
      cout << ans[tmp] << "\n";
    }
  }
  return 0;
}
