#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, cnt = 0, total = 0;
    cin >> n;
    while (n > 0) {
      cnt += (n % 2);
      total++;
      n /= 2;
    }
    if (total == cnt) {
      int flag = 0;
      int num = (1 << cnt) - 1;
      for (int i = 2; i <= sqrt(num); i++) {
        if (num % i == 0) {
          cout << num / i << endl;
          flag = 1;
          break;
        }
      }
      if (!flag) cout << 1 << endl;
    } else
      cout << (1 << total) - 1 << endl;
  }
}
