#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
long long p, maxn, maxid, res = 1;
vector<int>vec;
int primes[16] = { 1,2,3,5,7,11,13,17,19,23,29,31,37,41,43,47 };.
void dfs(long long q, long long r) {
long long sum = q;
for (int i = 1; i <= 1000; i++) {
if (sum > p) { break; }
if (i >= 2) {
vec.push_back(i); res *= i;
if (res > maxn) { maxn = res; maxid = sum; }
else if (res == maxn && maxid > sum) { maxid = sum; }
dfs(sum, i);
}
sum *= primes[vec.size()];
}
res /= vec[vec.size() - 1];
vec.pop_back();
return;
}
int Q;
int main() {
cin >> Q;
for (int i = 0; i < Q; i++) {
vec.clear(); maxn = 1; res = 1; maxid = 1;
vec.push_back(1);
cin >> p;
dfs(1, 20);
cout << maxn << ' ' << maxid << endl;
}
return 0;
}
I2luY2x1ZGU8aW9zdHJlYW0+CiNpbmNsdWRlPHZlY3Rvcj4KI2luY2x1ZGU8YWxnb3JpdGhtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwogCmxvbmcgbG9uZyBwLCBtYXhuLCBtYXhpZCwgcmVzID0gMTsKdmVjdG9yPGludD52ZWM7CmludCBwcmltZXNbMTZdID0geyAxLDIsMyw1LDcsMTEsMTMsMTcsMTksMjMsMjksMzEsMzcsNDEsNDMsNDcgfTsuIAp2b2lkIGRmcyhsb25nIGxvbmcgcSwgbG9uZyBsb25nIHIpIHsKCWxvbmcgbG9uZyBzdW0gPSBxOwoJZm9yIChpbnQgaSA9IDE7IGkgPD0gMTAwMDsgaSsrKSB7CgkJaWYgKHN1bSA+IHApIHsgYnJlYWs7IH0KCQlpZiAoaSA+PSAyKSB7CgkJCXZlYy5wdXNoX2JhY2soaSk7IHJlcyAqPSBpOwoJCQlpZiAocmVzID4gbWF4bikgeyBtYXhuID0gcmVzOyBtYXhpZCA9IHN1bTsgfQoJCQllbHNlIGlmIChyZXMgPT0gbWF4biAmJiBtYXhpZCA+IHN1bSkgeyBtYXhpZCA9IHN1bTsgfQoJCQlkZnMoc3VtL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