import Control.Applicative

main :: IO ()
main = do
  n  <- readLn
  xs <- map ((map read) . words) . take n . lines <$> getContents
  let ns = replicate (4 * 3 * 10) 0
  let ys = foldr g ns xs
        where g [b, f, r, v] ns = changeAt (toIndex (b, f, r)) v ns
  display 1 ys

toIndex :: (Int, Int, Int) -> Int
toIndex (b, f, r) = (b - 1) * 30 + (f - 1) * 10 + (r - 1)

changeAt :: Int -> Int -> [Int] -> [Int]
changeAt i n ns = as ++ ((b + n) : bs)
  where (as, b : bs) = splitAt i ns

display :: Int -> [Int] -> IO ()
display _ [] = return ()
display 4 xs = do
  putStrLn $ replicate 20 '#'
  display 1 xs
display i xs = do
  putStrLn $ ' ' : (unwords . map show $ as)
  display (i + 1) bs
    where (as, bs) = splitAt 10 xs

