#include <bits/stdc++.h>
using namespace std;
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
unordered_map<long long, pair<int, int>> f;
for (int i = 2; i <= 1e6; i++)
{
long long sum = 1+i, cur = i, d = 2;
while (sum <= 1e18)
{
if (cur > 1e18/i) break;
cur *= i;
sum += cur;
if (sum > 1e18) break;
if (f.find(sum) == f.end()) f[sum] = {i, d};
d++;
}
}
int t;
cin >> t;
while (t--)
{
long long n;
cin >> n;
pair<long long, int> ans = {LLONG_MAX, 0};
if (f.find(n) != f.end()) ans = f[n];
long long delta = 1 + 4*n - 4;
if (delta >= 0)
{
long double x = (sqrtl(delta)-1)/2.0;
if (abs(x-round(x)) < 1e-9 && x > 1) ans = min(ans, {x, 2});
}
if (ans.first == LLONG_MAX) cout << -1;
else cout << ans.first << ' ' << ans.second;
cout << '\n';
}
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+Cgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IG1haW4oKQp7ICAgIAogICAgaW9zX2Jhc2U6OnN5bmNfd2l0aF9zdGRpbygwKTsKICAgIGNpbi50aWUoMCk7CiAgICBjb3V0LnRpZSgwKTsKCiAgICB1bm9yZGVyZWRfbWFwPGxvbmcgbG9uZywgcGFpcjxpbnQsIGludD4+IGY7CiAgICBmb3IgKGludCBpID0gMjsgaSA8PSAxZTY7IGkrKykKICAgIHsKICAgICAgICBsb25nIGxvbmcgc3VtID0gMStpLCBjdXIgPSBpLCBkID0gMjsKICAgICAgICB3aGlsZSAoc3VtIDw9IDFlMTgpCiAgICAgICAgewogICAgICAgICAgICBpZiAoY3VyID4gMWUxOC9pKSBicmVhazsKICAgICAgICAgICAgY3VyICo9IGk7CiAgICAgICAgICAgIHN1bSArPSBjdXI7CiAgICAgICAgICAgIGlmIChzdW0gPiAxZTE4KSBicmVhazsKICAgICAgICAgICAgaWYgKGYuZmluZChzdW0pID09IGYuZW5kKCkpIGZbc3VtXSA9IHtpLCBkfTsKICAgICAgICAgICAgZCsrOwogICAgICAgIH0KICAgIH0KCiAgICBpbnQgdDsKICAgIGNpbiA+PiB0OwogICAgd2hpbGUgKHQtLSkKICAgIHsKICAgICAgICBsb25nIGxvbmcgbjsKICAgICAgICBjaW4gPj4gbjsKICAgICAgICBwYWlyPGxvbmcgbG9uZywgaW50PiBhbnMgPSB7TExPTkdfTUFYLCAwfTsKICAgICAgICBpZiAoZi5maW5kKG4pICE9IGYuZW5kKCkpIGFucyA9IGZbbl07CiAgICAgICAgbG9uZyBsb25nIGRlbHRhID0gMSArIDQqbiAtIDQ7CiAgICAgICAgaWYgKGRlbHRhID49IDApCiAgICAgICAgewogICAgICAgICAgICBsb25nIGRvdWJsZSB4ID0gKHNxcnRsKGRlbHRhKS0xKS8yLjA7CiAgICAgICAgICAgIGlmIChhYnMoeC1yb3VuZCh4KSkgPCAxZS05ICYmIHggPiAxKSBhbnMgPSBtaW4oYW5zLCB7eCwgMn0pOwogICAgICAgIH0KICAgICAgICBpZiAoYW5zLmZpcnN0ID09IExMT05HX01BWCkgY291dCA8PCAtMTsKICAgICAgICBlbHNlIGNvdXQgPDwgYW5zLmZpcnN0IDw8ICcgJyA8PCBhbnMuc2Vjb25kOwogICAgICAgIGNvdXQgPDwgJ1xuJzsKICAgIH0KCiAgICByZXR1cm4gMDsKfQo=