require("prime")

while num = gets
  num = num.to_i
  top = 0
  bottom = 0
  Prime.each do |prime|
    if prime > num then
      top = prime
      break
    end
    bottom = prime if num != prime
  end

  puts "#{bottom} #{top}"
end