#include <bits/stdc++.h>
using namespace std;
long long power(long long x, long long y) {
  int res = 1;
  if (x == 0) return 0;
  while (y > 0) {
    if (y & 1) res = (res * x);
    y = y >> 1;
    x = (x * x);
  }
  return res;
}
void solve() {
  int n;
  cin >> n;
  int ans = 0;
  for (int i = 2; i < n; i++) {
    int x = pow(2, i);
    x = x - 1;
    if (n % x == 0) {
      ans = n / x;
      break;
    }
  }
  cout << ans << "\n";
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
}
