while true
    p, n = gets.chomp.split.map(&:to_i)
    break if [n, p] == [0, 0]
    rootp = Math.sqrt(p)
    left, right = Rational(rootp.floor, 1), Rational(rootp.ceil, 1)
    2.upto(n){|i|
        r = Rational((rootp * i).floor, i)
        r = Rational([r.numerator, n].min, i)
        left = r if left < r
        r = Rational((rootp * i).ceil, i)
        r = Rational([r.numerator, n].min, i)
        right = r if right > r && r > rootp
    }
    puts "#{right} #{left}"
end
