#include <bits/stdc++.h>
using namespace std;
int dx[] = {-1, 1, 0, 0};
int dy[] = {0, 0, -1, 1};
vector<long long int> adj[200001];
bool vis[200001];
int C[501][5001];
long long int ans = 0;
long long int sizes[200001];
long long int arr[200001];
bool cycle[200001];
bool ok = true;
long long int level[200001];
long long int kid[200001];
long long int fa[200001];
long long int skill[200001];
bool cmp(long long int a, long long int b) { return (skill[a] < skill[b]); }
void dfs(long long int node, long long int lev) {
  vis[node] = true;
  level[node] = lev;
  for (long long int i = 0; i < adj[node].size(); i++) {
    if (!vis[adj[node][i]]) {
      dfs(adj[node][i], lev + 1);
      kid[node] += kid[adj[node][i]] + 1;
    }
  }
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  cin >> t;
  set<int> ss;
  int z = 2, y = 1;
  while (t--) {
    int n;
    bool ok = false;
    cin >> n;
    for (int i = 2; i * i <= n; i++) {
      if (n % i == 0) {
        int x = n / i, y = i;
        x++;
        if (!(x & (x - 1))) {
          ok = true;
          cout << y;
          break;
        }
        y++;
        if (!(y & (y - 1))) {
          ok = true;
          cout << x - 1;
          break;
        }
      }
    }
    if (!ok) cout << 1;
    cout << "\n";
  }
  return (0);
}
