#include using namespace std; #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) #define ll long long const long long mod=998244353; const long long hmod=46216567629137; int main(){ cin.tie(0)->sync_with_stdio(0); cout.tie(0); int T; cin>>T; mapdat; for(ll i=1;i*i<=1000000000000;i++){ ll now=i*i; string s=to_string(now); sort(s.begin(),s.end()); ll a=stoll(s); if(dat.count(a)==0) dat[a]=now; else dat[a]=min(dat[a],now); } for(int z=1;z<=T;z++){ ll N; cin>>N; string s=to_string(N); sort(s.begin(),s.end()); ll a=stoll(s); if(dat.count(a)){ cout<