import Control.Monad
import Control.Applicative
import Data.Functor
import Data.Monoid
import Data.Maybe
import Data.List
import Data.Foldable (foldMap)
import Data.List.Split
import Data.Char
import Data.Ratio
import Data.Ord
import Data.Array.IO

readInt = read :: String -> Int
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
-- end of templete

primes = primes' [2..50021]
  where
    primes' [] = []
    primes' (p:l) = (p : primes' [x | x <- l, mod x p /= 0])

f n = [last $ takeWhile (<n) primes, head $ dropWhile (<=n) primes]

main = do
    map readInt . lines <$> getContents >>= mapM_ (putStrLn . sjoin . f)