#include #define rep(i, l, r) for (int i = (l); i < (r); i++) using namespace std; typedef long long ll; int main() { set st; rep(i, 2, 1000001) { //cout << i << endl; for (ll j = 1LL * i * i; j <= 1e18 / i; j *= i) { ll x = j * i, y = sqrt(x); if (x != y * y) st.insert(x); } } //cout << st.size() << endl; //for (ll i : st) cout << i << " "; vector vc(0); for (ll i : st) vc.push_back(i); sort(vc.begin(), vc.end()); int T; cin >> T; while (T-- > 0) { ll K; cin >> K; priority_queue ans = {}; for (ll i = K; i > max(0LL, (ll)(K - vc.size())); i--) { ans.push(i * i); //cout << i * i << ":"; //cout << ans.size() << endl; } //cout << ans.size() << endl; for (ll i : vc) { ans.push(i); ans.pop(); } cout << ans.top() << endl; /* cout << ans.size() << endl; while (!ans.empty()) { cout << ans.top() << ";"; ans.pop(); } */ } //rep(i, 0, 100) cout << vc[vc.size() - 1 - i] << " "; }