raw = $stdin.readlines

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

for height in 1..149
  for width in (height + 1)..150
    square[height][width] = height**2 + width**2
  end
end


for line in raw 

  stnum = line.split(" ")
  inp_h = stnum[0].to_i()
  inp_w = stnum[1].to_i()

  if inp_h * inp_w == 0
    #do nothing
  else
    length = inp_h**2 + inp_w**2
    min_l = (150**2)*2
    min_h = inp_h
    min_w = 150

    for i in 1..149
      for j in (i + 1)..149
        if square[i][j] == length
          if i > inp_h
            if min_l != length || min_h > i
              min_l = length
              min_h = i
              min_w = j
            end
          end
        elsif square[i][j] > length
          if min_l > square[i][j]
            min_l = square[i][j]
            min_h = i
            min_w = j
          elsif min_l == square[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
end