def f(i, j)
  return i * i + j * j
end

loop do
  h, w = gets.chomp.split(" ").map(&:to_i)

  if h == 0 && w == 0
    break
  end

  ans_h = 200
  ans_w = 200
  
  for i in h..150
    for j in 1..150
      if i >= j
        next
      end
      d = f(i, j)
      if d == f(h, w) && i != h && i < ans_h
        ans_h = i
        ans_w = j
      end
    end
  end

  if ans_h == 200 && ans_w = 200
    for i in 1..150
      for j in 1..150
        if i >= j
          next
        end
        d = f(i, j)
        if d > f(h, w) && (d < f(ans_h, ans_w) || (d == f(ans_h, ans_w) && i < ans_h))
          ans_h = i
          ans_w = j
        end
      end
    end
  end
  
  puts "#{ans_h} #{ans_w}"
end