import Control.Monad

main = do
  (h:w:_) <- getLine >>= return . (map read) . words :: IO [Int]
  n <- readLn :: IO Int
  a <- getLine >>= return . (map read) . words :: IO [Int]

  let lst = func w (concat [take (a!!i) (repeat (i+1)) | i<-[0..length a-1]])
  let lst2 = map (unwords . (map show)) [if even i then (lst!!i) else reverse (lst!!i) | i<-[0..length lst-1]]

  mapM_ putStrLn lst2

  where
    func :: Int -> [a] -> [[a]]
    func _ [] = []
    func w xs = (take w xs) : (func w (drop w xs))

