#include <bits/stdc++.h>
using namespace std;
int main() {
  int q;
  cin >> q;
  while (q--) {
    int a;
    cin >> a;
    int i = 1, flag = 0;
    while (a >= i) {
      if ((i & a) == 0) flag = 1;
      i <<= 1;
    }
    if (flag)
      cout << i - 1 << endl;
    else {
      int temp = log2(a + 1) - 1;
      if (temp == 0) cout << 0 << endl;
      if (temp == 1) cout << 1 << endl;
      if (temp == 2) cout << 1 << endl;
      if (temp == 3) cout << 5 << endl;
      if (temp == 4) cout << 1 << endl;
      if (temp == 5) cout << 21 << endl;
      if (temp == 6) cout << 1 << endl;
      if (temp == 7) cout << 85 << endl;
      if (temp == 8) cout << 73 << endl;
      if (temp == 9) cout << 341 << endl;
      if (temp == 10) cout << 89 << endl;
      if (temp == 11) cout << 1365 << endl;
      if (temp == 12) cout << 1 << endl;
      if (temp == 13) cout << 5461 << endl;
      if (temp == 14) cout << 4681 << endl;
      if (temp == 15) cout << 21845 << endl;
      if (temp == 16) cout << 1 << endl;
      if (temp == 17) cout << 87381 << endl;
      if (temp == 18) cout << 1 << endl;
      if (temp == 19) cout << 349525 << endl;
      if (temp == 20) cout << 299593 << endl;
      if (temp == 21) cout << 1398101 << endl;
      if (temp == 22) cout << 178481 << endl;
      if (temp == 23) cout << 5592405 << endl;
      if (temp == 24) cout << 1082401 << endl;
    }
  }
  return 0;
}
