-- AtCoder My Practice
-- author: Leonardone @ NEETSDKASU

main = putStrLn . unlines . map (unwords.map show) .  solve . map read . words =<< getContents

solve (h:w:n:xs) = zs where
    ys = concat $ zipWith replicate xs [1..]
    zs = f ys 0
    f [] _ = []
    f ss i = vv : f ww (i+1) where
        (uu, ww) = splitAt w ss
        vv = if mod i 2 == 0 then uu else reverse uu