import Data.List

main = interact $ unlines . map (show' . mspf . read) . init . lines
 where show' (n,ns) = show n ++ ": " ++ unwords (map show ns)

mspf n = (n, sort (nub (msd n)))

msd n = msd' n [] msprimes
 where
  msd' n' ds pps@(p:ps)
   | p > n = ds
   | mod n' p /= 0 = msd' n' ds ps
   | otherwise = msd' (div n' p) (p:ds) pps ++ msd' n' ds ps

msprimes = 6 : 8 : union [13,20..] [15,22..]
 where
  union xxs@(x:xs) yys@(y:ys)
   | x<=y = if ismsp x then x : union xs yys else union xs yys
   | x>y = if ismsp y then y : union xxs ys else union xxs ys
  ismsp n = null [i | i <- takeWhile (\x -> x*x <= n) msprimes, mod n i == 0]