#include using namespace std; using ll = long long; bool chmin(auto &a, auto b) { return a > b ? a = b, true : false; } bool chmax(auto &a, auto b) { return a < b ? a = b, true : false; } void solve() { string N; cin >> N; sort(N.begin(), N.end()); do { int x = stoi(N); int y = sqrt(x); if(y*y == x) { cout << x << endl; return; } } while(next_permutation(N.begin(), N.end())); cout << -1 << endl; return; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int T; cin >> T; for(int i=0; i