diagonal = Array.new(150){Array.new(150)}

for i in 1..150
  for j in (i+1)..150
    diagonal[i][j] = i*i + j*j
  end
end

while true
  h, w = gets.split(/ /).map(&:to_i)
  
  if h == 0 && w == 0
    break
  end

  length = h*h + w*w
  min_length = (150*150)*2
  min_h = h
  min_w = 150
  
  for i in 1..150
    for j in (i+1)..150
      if diagonal[i][j] == h*h + w*w
        if i > h
          if min_length != length || min_h > i
            min_length = length
            min_h = i
            min_w = j
          end
        end
      elsif diagonal[i][j] > length
        if min_length > diagonal[i][j]
          min_length = diagonal[i][j]
          min_h = i
          min_w = j
        elsif min_length == diagonal[i][j] && min_h > i
          min_h = i
          min_w = j
        end
      end
    end
  end
  puts min_h.to_s + " " + min_w.to_s
end
