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

require 'prime'
class Main
  def ud(n)
    i = n.odd? ? n-2 : n-1
    while true do
      if Prime::prime?(i) then
        break
      end
      i -= 2
      if i<=1 then
        abort("not found")
      end
    end

    return i
  end

  def ov(n)
    i = n.odd? ? n+2 : n+1
    while true do
      if Prime::prime?(i) then
        break
      end
      i += 2
    end
    return i
  end

  def initialize
    fh = STDIN
    while fh.gets do
      n = $_.to_i
      printf("%d %d\n", ud(n), ov(n))
    end
  end

end

if $0 == __FILE__ then
  Main.new
end