import System.IO (isEOF)

main = do
    quit <- isEOF
    if quit then return () else do
        input >>= return . solve >>= output
        main

input :: IO (Int)
input = readLn

output :: (Int,Int) -> IO ()
output (a,b) = putStrLn $ unwords [show a, show b]

solve :: Int -> (Int,Int)
solve n = (maxPrimeLT n, minPrimeGT n)
    where
    maxPrimeLT n = head $ filter isPrime [n-1,n-2..]
    minPrimeGT n = head $ filter isPrime [n+1,n+2..]

isPrime n = isPrime' n 2
    where
    isPrime' n m
        | n < m^2 = True
        | n `mod` m == 0 = False
        | otherwise = isPrime' n (m+1)