f n (0:as) = f (n+1) as
f n (a:as) = n : f n (a-1:as)
g 0 _ _ = []
g h w xs = ys : g (h-1) w zs
  where (ys,zs) = splitAt w xs
main = do
  [h,w] <- map read . words <$> getLine
  getLine
  as <- map read . words <$> getLine
  mapM (putStrLn . unwords . map show) 
    $ zipWith ($) (cycle [id,reverse]) (g h w (f 1 as))