#include <bits/stdc++.h>
using namespace std;
template <class t>
istream& operator>>(istream& in, vector<t>& v) {
  for (auto& x : v) in >> x;
  return in;
}
template <class t1, class t2>
istream& operator>>(istream& in, pair<t1, t2>& v) {
  in >> v.first >> v.second;
  return in;
}
template <class t1, class t2>
ostream& operator<<(ostream& out, const pair<t1, t2>& a) {
  out << a.first << " " << a.second;
  return out;
}
template <class t>
ostream& operator<<(ostream& out, vector<t>& a) {
  for (auto x : a) out << x << " ";
  return out;
}
template <class t>
ostream& operator<<(ostream& out, set<t>& a) {
  for (auto x : a) out << x << " ";
  return out;
}
template <class t>
ostream& operator<<(ostream& out, multiset<t>& a) {
  for (auto x : a) out << x << " ";
  return out;
}
template <class t1, class t2>
ostream& operator<<(ostream& out, map<t1, t2>& a) {
  for (auto x : a) out << x.first << " = " << x.second << endl;
  return out;
}
template <class t>
ostream& operator<<(ostream& out, deque<t>& d) {
  for (auto x : d) {
    out << x << " ";
  }
  return out;
}
template <class t1, class t2>
pair<t1, t2> operator+(const pair<t2, t1>& a, const pair<t1, t2>& b) {
  return {a.first + b.first, a.second + b.second};
}
template <class t1, class t2>
pair<t1, t2> operator-(const pair<t2, t1>& a, const pair<t1, t2>& b) {
  return {a.first - b.first, a.second - b.second};
}
template <class t1, class t2>
pair<t1, t2> operator+=(pair<t2, t1>& a, const pair<t1, t2>& b) {
  return {a = a + b};
}
template <class t1, class t2>
pair<t1, t2> operator-=(pair<t2, t1>& a, const pair<t1, t2>& b) {
  return {a = a - b};
}
long long gcd(long long a, long long b) {
  while (b != 0) {
    long long x = a;
    a = b, b = x % b;
  }
  return a;
}
long long lcm(long long a, long long b) { return a * (b / gcd(a, b)); }
long long fpow(long long b, long long e, long long m = (long long)(100000007)) {
  long long r = 1;
  while (e) {
    if (e & 1) r = (r * b) % m;
    e /= 2;
    b = (b * b) % m;
  }
  return r;
}
int32_t main(int32_t argc, char const* argv[]) {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    long long k = 3;
    while (1) {
      if (n % k == 0) {
        cout << n / k << "\n";
        break;
      }
      k = k * 2 + 1;
    }
  }
  return 0;
}
