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

require 'prime'
class Main

  def initialize
    fh = STDIN
    while fh.gets do
      n = $_.chomp.to_i
      pr = []
      i = n.odd? ? n-2 : n-1
      while true do
        if Prime::prime?(i) then
          pr.push i
          break
        end
        i -= 2
        abort("not found") if i<=1
      end
      i = n.odd? ? n+2 : n+1
      while true do
        if Prime::prime?(i) then
          pr.push i
          break
        end
        i += 2
      end
      puts pr.map{|x|x.to_s}.join(" ")
  end
    end

end

if $0 == __FILE__ then
  Main.new
end