d = Hash.new
1.upto(150) do |i|
    (i+1).upto(150) do |j|
        d[[i,j]] = i**2 + j**2
    end
end
d = d.sort{|a,b| (a[1] <=> b[1]).nonzero? || a[0][0] <=> b[0][0]}.to_a
loop do
    h, w = gets.split.map(&:to_i)
    break if h == 0 && w == 0
    puts [d[d.index([[h,w], h**2 + w**2]) + 1][0]].map{|i| "#{i[0]} #{i[1]}"}
end