#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
long long a[t + 5];
for (int i = 0; i < t; i++) {
cin >> a[i];
}
for (int i = 0; i < t; i++) {
for (int j = 0; j * j * j * j < a[i]; j++) {
if (a[i] == j * j * j * j) {
cout << j << endl;
continue;
}
}
}
cout << "-1";
return 0;
}