main = do
  s <- getContents
  let primes = 2 : filter (\n -> n > 1 && foldr (\x acc -> x * x > n || (n `mod` x /= 0 && acc)) True primes) [3, 5..]
  mapM_ (\n -> putStrLn . unwords $ map show $ [last $ takeWhile (< n) primes, head $ dropWhile (<= n) primes]) . map read $ lines s