### constant

MAX_H = MAX_W = 150

### main

rects = []

for h in (1..MAX_H)
  for w in ((h + 1)..MAX_W)
    rects << [h * h + w * w, h, w]
  end
end
rects.sort!

loop do
  h, w = gets.split.map(&:to_i)
  break if (h | w) == 0

  d = h * h + w * w
  i = rects.index([d, h, w])

  dj, hj, wj = rects[i + 1]
  puts [hj, wj].join(' ')
end