import Control.Monad
main = do
  [h,w]<- fmap (map read . words) getLine
  _ <-  getLine
  a's <- fmap (map read . words) getLine
  let dat = analyze h w a's
  prettyprint dat

analyze :: Int -> Int -> [Int] -> [[Int]]
analyze h w a's = neaten w $ concat [ replicate v u | (u,v) <- zip [1..] a's]

neaten :: Int -> [a] -> [[a]]
neaten w [] = []
neaten w arr = take w arr : map reverse (neaten w (drop w arr))

prettyprint :: [[Int]] -> IO ()
prettyprint ks = forM_ ks $ \k -> do
  putStrLn (unwords . map show $ k)
