#include //#include using namespace std; //using namespace atcoder; using ll = long long; #define all(A) A.begin(),A.end() using vll = vector; #define rep(i, n) for (long long i = 0; i < (long long)(n); i++) using Graph = vector>; vll P = {5,7,11,13,17,19,23,29,31,37}; vector PP(P.size()); set S; vll PPP; bool isOK(ll index, ll key) { ll k = 0; ll D = sqrt(index); D = max(0ll, D - 5); rep(i, 11) { if (D * D <= index) { D++; } else { D--; break; } } k += D; D = cbrt(index); D = max(0ll, D - 5); rep(i, 11) { if (D * D*D <= index) { D++; } else { D--; break; } } k += D-1; auto Ds = upper_bound(all(PPP),index)-PPP.begin(); k += (Ds); return (k >= key); } // 汎用的な二分探索のテンプレ ll binary_search(ll key) { ll ng = 0; //「index = 0」が条件を満たすこともあるので、初期値は -1 ll ok = key * key+3; // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size() /* ok と ng のどちらが大きいかわからないことを考慮 */ while (abs(ok - ng) > 1) { ll mid = (ok + ng) / 2; cout << ""; if (isOK(mid, key)) ok = mid; else ng = mid; } return ok; } int main() { //set S; //S.insert(2e18); PPP.push_back(1e18+10); rep(i, P.size()) { ll p = P[i]; ll k = 2; while (1) { ll d = k; bool c = true; rep(u, p - 1) { if (d <= (1e18+10) / k) { d *= k; } else { c = false; break; } } if (c) { ll D = sqrt(d); bool ks = true; rep(i, 11) { if (D - 5 + i <= 0)continue; if ((D - 5 + i) * (D - 5 + i) == d)ks = false; if (d % (D - 5 + i) == 0 && (D - 5 + i) * (D - 5 + i) == d / (D - 5 + i))ks = false; } if (ks&&!S.count(d)) { S.insert(d); PPP.push_back(d); } } else { //PP[i].push_back(2e18); break; } k++; d = 0; } } sort(all(PPP)); ll T; cin >> T; rep(t, T) { ll N; cin >> N; cout << binary_search(N) << endl; } }