#!/usr/bin/ruby
# -*- coding: utf-8 -*-
=begin
Volume0-0044
Prime Number II
=end

require 'prime'
class P

  def initialize(ulimit)
    @p = [2] + 3.step(ulimit,2).to_a.select{|x| Prime.prime?(x)} 
  end

  def ud(n)
    @p.select{|x| x < n}.last
  end

  def ov(n)
    @p.select{|x| x > n}.first
  end

end

class Main

  def initialize
    fh = STDIN
    #fh = "x.txt"
    p = P.new(50050)
    while fh.gets do
      n = $_.to_i
      printf("%d %d\n", p.ud(n), p.ov(n))
    end
  end

end

if $0 == __FILE__ then
  Main.new
end