#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) {
  if (a == 0) return b;
  return b == 0 ? a : gcd(b, b % a);
}
vector<int> v;
vector<int> sum;
int main() {
  v.push_back(1);
  sum.push_back(1);
  for (int i = 0; i < 27; i++) {
    v.push_back(v.back() * 2);
    sum.push_back(sum.back() + v.back());
  }
  int T;
  scanf("%d", &T);
  while (T--) {
    int num;
    scanf("%d", &num);
    int rec = lower_bound(sum.begin(), sum.end(), num) - sum.begin();
    if (sum[rec] != num) {
      cout << sum[rec] << endl;
    } else {
      if (num == 3) {
        cout << 1 << endl;
        continue;
      }
      int rec = sqrt(num);
      int ans = 1;
      for (int i = 3; i <= rec; i++) {
        if (num % i) continue;
        ans = num / i;
        break;
      }
      cout << ans << endl;
    }
  }
}
