primes :: [Integer]
primes = 2 : filter isPrime [3,5..]
  where isPrime n = n > 1 && foldr (\x acc -> x * x > n || (n `mod` x /= 0 && acc)) True primes

solve :: Integer -> (Integer, Integer)
solve n = let (ps1, ps2) = span (<n) primes
              ps3        = dropWhile (<=n) ps2
          in  (last ps1, head ps3)

main :: IO ()
main = getContents >>= mapM_ (printResult . solve . read) . lines
  where printResult (a, b) = putStrLn $ show a ++ " " ++ show b