import Text.Printf
import Control.Monad
import Data.Char
import Data.List
import Debug.Trace

eratosthenes :: ([Int],[Int]) -> [Int]
eratosthenes (tosearch, primes) = 
    if (head tosearch)*(head tosearch)>=(last tosearch) then sort $ tosearch++primes
    else eratosthenes (tosearch', primes')
    where
        primes' = primes ++ [head tosearch]
        tosearch' = filter (\x->(x`mod`(head tosearch))/=0) tosearch

primes :: [Int]
primes = eratosthenes([2..50021], [])

solve :: Int -> IO ()
solve n = do 
    let pmax = last $ takeWhile (<n) primes
    let pmin = head $ filter (>n) primes
    printf "%d %d\n" pmax pmin

main :: IO ()
main = do
    s<-getContents :: IO String 
    mapM_ solve $ map (\x->read x::Int) $ lines $ s