#include <bits/stdc++.h>
using namespace std;
bool aman(long long int n) {
  if (n <= 1) return false;
  if (n <= 3) return true;
  if (n % 2 == 0 || n % 3 == 0) return false;
  for (long long int i = 5; i * i <= n; i = i + 6)
    if (n % i == 0 || n % (i + 2) == 0) return false;
  return true;
}
int saxena(int x, unsigned int y, int p) {
  int res = 1;
  x = x % p;
  if (x == 0) return 0;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t;
  cin >> t;
  long long l, a[33] = {0};
  for (int l = 2; l < 32; l++) {
    a[l] = saxena(2, l, 1000000007) - 1;
  }
  while (t--) {
    long long int n, i, c = 0;
    cin >> n;
    long long aman = 0, a[33] = {0};
    for (int i = 2; i < 32; i++) {
      a[i] = saxena(2, i, 1000000007) - 1;
    }
    for (int i = 2; i < 32; i++) {
      c = (long long int)(n % a[i]);
      if (c == 0) {
        cout << (long long int)(n / a[i]) << '\n';
        break;
      }
    }
  }
  return 0;
}
