#include <bits/stdc++.h>
using namespace std;
const int inf = (int)1e9 + 5;
const int mod = (int)1e9 + 7;
int main() {
  int q;
  cin >> q;
  while (q--) {
    long long a;
    cin >> a;
    long long i = 0, ms = 0;
    long long a1 = a;
    while (a > 0) {
      if (a & 1) ms = i;
      a >>= 1;
      i++;
    }
    ++ms;
    ms = (1ll << ms) - 1;
    if (a1 == ms) {
      ms = 1;
      for (long long y = 2; y * y <= a1; y++)
        if (a1 % y == 0) {
          ms = a1 / y;
          break;
        }
      cout << ms << endl;
      continue;
    } else {
      cout << ms << endl;
    }
  }
  return 0;
}
