# ??\????????????????????? http://icpc.iisf.or.jp/past-icpc/domestic2013/ ????????????

def less(x,y)
  x[0] < y[0] || (x[0] == y[0] && x[1] < y[1])
end

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

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

  input = [h*h+w*w, h]
  ans = [(151**2)*2, 151]
  answh = [-1, -1]

  (1..150).each do |i|
    (i+1..150).each do |j|
      t = [i*i+j*j, i]

      if less( input, t ) && less( t, ans )
        ans = t
        answh = [i, j]
      end
    end
  end

  puts answh.join(' ')
end