import Control.Monad (forM_)
import Data.List (sortBy)

splitBy _ [] = []
splitBy w cs = take w cs:splitBy w (drop w cs)

main :: IO ()
main = do
  [h,w] <- map read.words <$> getLine :: IO [Int]
  n <- read <$> getLine :: IO Int
  as <- map read.words <$> getLine :: IO [Int]
  let ls = splitBy w $ concatMap (uncurry replicate) $ sortBy (flip compare) $ zip as [1..]
  forM_ (zip ls [1..])$ \(l,i) ->
    putStrLn $ unwords $ map show $ if odd i then l else reverse l
