#include #include using namespace std; using namespace atcoder; #define rep(i,n)for (int i = 0; i < int(n); ++i) #define rrep(i,n)for (int i = int(n)-1; i >= 0; --i) #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() template void chmax(T& a, const T& b) {a = max(a, b);} template void chmin(T& a, const T& b) {a = min(a, b);} using ll = long long; using P = pair; using VI = vector; using VVI = vector; using VL = vector; using VVL = vector; constexpr ll MX = 1000000000'000000000; bool is_square(ll x) { ll l = 1, r = 2; while(r * r <= x) l = r, r *= 2; while(r - l > 1) { ll c = (l + r) / 2; if (c * c <= x) l = c; else r = c; } return l * l == x; } int main() { ios::sync_with_stdio(false); cin.tie(0); VL d; for(int b = 3; b < 60; b++) { for(ll a = 2;; a++) { long long ab = 1; bool ok = true; rep(_, b) { if (ab > MX / a) { ok = false; break; } ab *= a; } if (!ok) break; if (!is_square(ab)) d.push_back(ab); } } sort(all(d)); d.erase(unique(all(d)), d.end()); // cout << d.size() << endl; // return 0; // rep(i, 10) cout << d[i] << " "; // cout << endl; int tt; cin >> tt; while(tt--) { int k; cin >> k; ll l = 1, r = 1000000001; while(r - l > 1) { ll c = (l + r) / 2; // # of <= c^2 ll cnt = c + (lower_bound(all(d), c * c) - d.begin()); if (cnt <= k) l = c; else r = c; } auto it = lower_bound(all(d), l * l); ll cnt = l + (it - d.begin()); int rest = k - cnt; // cout << l << ' ' << r << ' ' << rest << ' ' << (it - d.begin()) << endl; if (rest == 0) { cout << l * l << '\n'; } else { cout << it[rest - 1] << '\n'; } } }