### main

loop do
  pn, n = gets.split.map(&:to_i)
  break if (pn | n) == 0

  uv = 0
  xy = pn
  
  for den in (1..n)
    for num in (den..n)
      r = Rational(num, den)
      r2 = r * r

      if r2 < pn
        uv = r if uv < r
      elsif r2 > pn
        xy = r if xy > r
      end
    end
  end

  puts [xy, uv].join(' ')
end