#include <bits/stdc++.h>
using namespace std;
int main() {
  int q, a;
  cin >> q;
  while (q--) {
    cin >> a;
    int p = 1;
    while (p <= a) p *= 2;
    if (a != p - 1)
      cout << p - 1 << endl;
    else {
      bool ok = false;
      for (int d = 2; d * d <= a; d++) {
        if (a % d == 0) {
          cout << a / d << endl;
          ok = true;
          break;
        }
      }
      if (!ok) cout << 1 << endl;
    }
  }
  return 0;
}
