import Control.Monad
import Data.List
main = do
    [h, w] <- map read . words <$> getLine :: IO [Int]
    getLine
    as <- map read . words <$> getLine
    mapM_ putStrLn $ map (intercalate " ") $ zipWith ($) (cycle [id, reverse]) $ splitRec w $ concat $ zipWith replicate as $ map show [1..]
  where
    splitRec _ [] = []
    splitRec k xs = let (t,d) = splitAt k xs in t : splitRec k d