require "prime"
while n = gets
  n = n.chomp.to_i
  min = Prime.each(n-1){|prime| prime }

  while true
    n += 1
    if Prime.prime?(n)
      max = n; break
    end
  end

  puts "#{min} #{max}"
end