import Control.Applicative ((<$>), (<*>))
import Control.Monad
import Data.List

main :: IO ()
main = do
  n <- getl toInt
  when (n /= 0) $ do
  putStrLn . unwords . map show $ solve n
  main

solve :: Int -> [Int]
solve x = twinpn pn
  where
    pn = reverse . takeWhile (< x) $ primeNum

primeNum = 2 : sieve [3,5..]
sieve (x:xs) = x : sieve [y | y <- xs, y `mod` x /= 0]

twinpn :: [Int] -> [Int]
twinpn (x:y:ys)
  | x == y + 2 = [y, x]
  | otherwise = twinpn (y:ys)

toInt :: String -> Int
toInt s = read s

getl :: (String -> a) -> IO a
getl f = f <$> getLine