import Control.Monad (forM_)

main = do
    n <- readLn
    if n == 0 then return () else do
        forM_ (solve n) (putStrLn . unwords . map show)
        main

solve :: Int -> [[Int]]
solve n = map extract (divisions n)

type Count = Int

divisions :: Int -> [[(Int,Count)]]
divisions n = spare n n
    where
    spare 1 r = [[(1,r)]]
    spare m r = concatMap spare' [c,c-1..0]
        where
        spare' c = map ((m,c):) (spare (m-1) (r-m*c))
        c = r `div` m

extract :: [(Int,Count)] -> [Int]
extract = concatMap (\(n,c) -> replicate c n)