#include<bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i=(a), _b=(b); i<_b; ++i)
#define fi first
#define se second
#define pb push_back
#define ll long long
#define sz(a) a.size()
#define all(a) a.begin(),a.end()
const int N = 1 + 1e7;
const int INF = 1e9;
int t;
vector <int> p;
vector <bool> prime(N + 9, true);
void sang() {
p.pb(2);
for(ll i = 3; i <= N; i += 2)
if(prime[i] == true) {
p.pb(i);
for(ll j = i * i; j <= N; j += i * 2)
prime[j] = false;
}
}
void solve() {
ll n;
cin >> n;
for(auto i : p) {
if(i * i > n) // => n là số nguyên tố vì n không có ước nguyên tố từ 1 -> sqrt(n)
break;
if(n % i == 0) {
cout << n / i << '\n';
return; // kết thúc hàm
}
}
cout << -1 << '\n';
}
int32_t main() {
ios_base::sync_with_stdio (false);
cin.tie(NULL); cout.tie(NULL);
sang();
cin >> t;
while(t--)
solve();
return 0;
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKI2RlZmluZSBGT1IoaSwgYSwgYikgZm9yKGludCBpPShhKSwgX2I9KGIpOyBpPF9iOyArK2kpCiNkZWZpbmUgZmkgZmlyc3QKI2RlZmluZSBzZSBzZWNvbmQKI2RlZmluZSBwYiBwdXNoX2JhY2sKI2RlZmluZSBsbCBsb25nIGxvbmcKI2RlZmluZSBzeihhKSBhLnNpemUoKQojZGVmaW5lIGFsbChhKSBhLmJlZ2luKCksYS5lbmQoKQpjb25zdCBpbnQgTiA9IDEgKyAxZTc7CmNvbnN0IGludCBJTkYgPSAxZTk7CgppbnQgdDsKCnZlY3RvciA8aW50PiBwOwp2ZWN0b3IgPGJvb2w+IHByaW1lKE4gKyA5LCB0cnVlKTsKCnZvaWQgc2FuZygpIHsKICAgIHAucGIoMik7CiAgICBmb3IobGwgaSA9IDM7IGkgPD0gTjsgaSArPSAyKQogICAgICAgIGlmKHByaW1lW2ldID09IHRydWUpIHsKICAgICAgICAgICAgcC5wYihpKTsKICAgICAgICAgICAgZm9yKGxsIGogPSBpICogaTsgaiA8PSBOOyBqICs9IGkgKiAyKQogICAgICAgICAgICAgICAgcHJpbWVbal0gPSBmYWxzZTsKICAgICAgICB9Cn0KCnZvaWQgc29sdmUoKSB7CiAgICBsbCBuOwogICAgY2luID4+IG47CiAgICBmb3IoYXV0byBpIDogcCkgewogICAgICAgIGlmKGkgKiBpID4gbikgLy8gPT4gbiBsw6Agc+G7kSBuZ3V5w6puIHThu5EgdsOsIG4ga2jDtG5nIGPDsyDGsOG7m2Mgbmd1ecOqbiB04buRIHThu6sgMSAtPiBzcXJ0KG4pIAogICAgICAgICAgICBicmVhazsKICAgICAgICBpZihuICUgaSA9PSAwKSB7CiAgICAgICAgICAgIGNvdXQgPDwgbiAvIGkgPDwgJ1xuJzsKICAgICAgICAgICAgcmV0dXJuOyAvLyBr4bq/dCB0aMO6YyBow6BtCiAgICAgICAgfQogICAgfQogICAgY291dCA8PCAtMSA8PCAnXG4nOwp9CgppbnQzMl90IG1haW4oKSB7CiAgICBpb3NfYmFzZTo6c3luY193aXRoX3N0ZGlvIChmYWxzZSk7CiAgICBjaW4udGllKE5VTEwpOyBjb3V0LnRpZShOVUxMKTsKICAgIHNhbmcoKTsKICAgIGNpbiA+PiB0OwogICAgd2hpbGUodC0tKSAKICAgICAgICBzb2x2ZSgpOwogICAgcmV0dXJuIDA7Cn0=