uses crt;
var i:longint;
{-----------------------------------------------------------}
function kt(x:longint):boolean;
var st,s:string;
i,a,b,o:longint;
begin
str(x,st);
s:='';
for i:=1 to length(st) do
begin
if i=4 then begin
val(s,a,o);
s:='';
end;
s:=s+st[i];
val(s,b,o);
end;
if b-a=4 then kt:=true
else kt:=false;
end;
{-----------------------------------------------------------}
begin
clrscr;
for i:=100000 to 999999 do
if (i=sqr(round(sqrt(i)))) and (kt(i)) then
writeln(i);
readln;
end.