#include <bits/stdc++.h>
using namespace std;
int main() {
  int q, f;
  cin >> q;
  long long int val, sum = 0, c;
  while (q--) {
    sum = 0, c = 0, f = 0;
    int mx = 1, i;
    cin >> val;
    int temp = val;
    while (val > 0) {
      c++;
      if ((val & 1) == 0) {
        f = 1;
      }
      val = val >> 1;
    }
    if (f == 1) {
      sum = pow(2, c) - 1;
      cout << sum << endl;
      continue;
    } else {
      for (i = 2; i * i <= (temp); i++) {
        if (temp % i == 0) {
          mx = temp / i;
          break;
        }
      }
    }
    cout << mx << endl;
  }
  return 0;
}
