import Control.Applicative

divide :: Int -> [Int] -> [[Int]]
divide _ [] = []
divide n xs = [take n xs] ++ divide n (drop n xs)

mapeven f [] =[]
mapeven f [x] =[x]
mapeven f (x:y:xs) = x:(f y):(mapeven f xs)

evenflip = mapeven reverse

collist0 :: Int -> [Int]->[Int]
collist0 _ [] = []
collist0 n (x:xs) = (replicate x n) ++ collist0 (n+1) xs

collist = collist0 1

solver w as = evenflip $ (divide w) (collist as)

myshow = unwords.(map show)

showIO [xs] = do putStrLn $ myshow xs
showIO (xs:xss) = do
    putStrLn $ myshow xs
    showIO xss

main :: IO ()
main = do
    [_,w] <- map read . words <$> getLine 
    getLine 
    as <- map read . words <$> getLine 
    showIO $ solver w as

