program lygybe;
  { 17 u‘davinys }
  var a, b, c, d : integer;
begin
  for a := 1 to 9 do
    for b := 0 to 9 do
      for c := 0 to 9 do
        for d := 0 to 9 do
          if a + b + c + d < 10
             then if sqr (sqr (a + b + c + d)) =
                     a * 1000 + b * 100 + c * 10 + d
                     then writeln (a * 1000 + b * 100 + c * 10 + d)
end.