#include using namespace std; #define bokusunny ios::sync_with_stdio(false), cin.tie(nullptr); bool is_prime(long long x) { if (x == 1) return false; long long i = 2; while (i * i <= x) { if (x % i == 0) return false; i++; } return true; } void solve() { long long x; cin >> x; vector P; for (int p = 2; p <= 31; p++) { if (is_prime(p)) P.push_back(p); } for (long long y = x * 2; y <= x * 31; y += x) { long long xx = x; long long yy = y; long long cntx = 1; long long cnty = 1; for (auto &p : P) { int ex = 1; while (xx % p == 0) { xx /= p; ex++; } cntx *= ex; int ey = 1; while (yy % p == 0) { yy /= p; ey++; } cnty *= ey; } if ((cnty >> 1) == cntx) { cout << y << endl; return; } } assert(false); } int main() { bokusunny; int t; cin >> t; while (t--) solve(); return 0; }