#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e15 + 7;
const long long MAX = 1e5 + 7;
const long long MOD = 1e9 + 7;
typedef vector<long long> vi;
typedef vector<vi> vvi;
typedef vector<pair<long long, long long> > vii;
typedef vector<vii> vvii;
typedef vector<bool> vb;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long(t);
  cin >> (t);
  while ((t)--) {
    long long n;
    cin >> n;
    long long p = 1, ans = n;
    for (long long k = 0; k <= log2l(n + 5); k++) {
      p = p * 2;
      long long x = p - 1;
      if (n % x == 0 && k > 0) {
        ans = n / x;
        break;
      }
    }
    cout << ans << "\n";
  }
  return 0;
}
