#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0, f = 1;
  char c = getchar();
  for (; !isdigit(c); c = getchar())
    if (c == '-') f = -1;
  for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
  return x * f;
}
const int MAXN = 200010;
inline void solve() {
  int x = read();
  for (int i = 2; i <= 30; i++)
    if (x % ((1 << i) - 1) == 0) {
      printf("%d\n", x / ((1 << i) - 1));
      return;
    }
}
int main() {
  for (int Cas = read(); Cas; Cas--) solve();
  return 0;
}
