l = 7368791
a = Array.new(l + 1, true)

queries = []
loop do
    m, n = gets.split.map(&:to_i)
    break if m == 0
    queries << [m, n]
end

ans = {}
m0 = l / 2 + 1
queries.sort.reverse.each do |m, n|
    while m0 > m
        m0 -= 1
        (2..l).each do |y|
            k = m0 * y
            break if k > l
            a[k] = false
        end
    end
    k = 0
    m.upto(Float::INFINITY) do |x|
        k += 1 if a[x]
        if k > n
            ans[[m, n]] = x
            break
        end
    end
end

queries.each do |a|
    p ans[a]
end

