eratosthenes = Array.new(50022, true)
eratosthenes[0..1] = [false, false]
primes = []

i = 2
while i <= 50021
    if eratosthenes[i]
        m = 2
        while i * m <= 50021
            eratosthenes[i * m] = false
            m += 1
        end
    end
    i += 1
end
eratosthenes[2..-1].each_with_index{|x, i| primes << (i + 2) if x}

while line = gets
    n = line.to_i
    i = primes.rindex{|x| x < n}
    puts "#{primes[i]} #{(n != primes[i + 1]) ? primes[i + 1] : primes[i + 2]}"
end
