#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[]) {
  int t, j, c;
  long long int n, current, result;
  vector<long long int> hello;
  scanf("%d", &t);
  for (int i = 0; i < t; ++i) {
    scanf("%lld", &n);
    hello.push_back(n);
  }
  for (int i = 0; i < t; ++i) {
    current = hello.at(i);
    c = 3;
    j = 2;
    while (current % c != 0) {
      c = pow(2, j) - 1;
      j++;
    }
    result = current / c;
    printf("%lld\n", result);
  }
  return 0;
}
