import Data.Array

--?´???°?????????
primes = 2: filter isPrime [3,5..10000]
isPrime n = all ((>0).(rem n)) $ takeWhile (??x -> x*x <= n) primes

--???????´???°?????????
twinPrimes = filter filt $ zip primes (tail primes)
  where
    filt (a,b) = a + 2 == b

--???????´???°????????????????????????????´?
--????????\?????????????´???°????????§??????????´???????
winPrimesArray = array (5,10000) [(i,last (takeWhile (filt2 i) twinPrimes))| i <- [5..10000]]
  where
    filt2 i (a,b) = b <= i

--????????????String???????????¢??°
tpToStr (a,b) = show a ++ " " ++ show b

main = do
  s <- readLn
  if s == 0 then return ()
  else do
    putStrLn $ tpToStr $ winPrimesArray ! s
    main