#include <bits/stdc++.h>
template <typename T>
T GCD(T a, T b) {
  return a ? GCD(b % a, a) : b;
}
template <typename T>
T LCM(T a, T b) {
  return (a * b) / GCD(a, b);
}
using ld = double;
using ll = long long int;
using ul = unsigned long long int;
using namespace std;
class Candies {
 public:
  void solve(std::istream &in, std::ostream &out) {
    int n, sum = 1;
    in >> n;
    for (int i = 1; i < 30; i++) {
      sum += pow(2, i);
      if (n % sum == 0) {
        out << n / sum << endl;
        return;
      }
    }
  }
};
int main() {
  std::ios_base::sync_with_stdio(0);
  std::cin.tie(nullptr);
  Candies solver;
  std::istream &in(std::cin);
  std::ostream &out(std::cout);
  int n;
  in >> n;
  for (int i = 0; i < n; ++i) {
    solver.solve(in, out);
  }
  return 0;
}
