{-# LANGUAGE BangPatterns #-}

module Main where

import Data.Char
import Data.List
import Control.Monad
import Control.Monad.ST
import Data.Array.ST
import Data.Array.Unboxed
import Control.Applicative
import Text.Printf


readInt :: IO Int
readInt = read <$> (input `seq` input)
    where input = do
            !c <- getChar
            if isDigit c || c == '-'
                then (c :) <$> input
                else return []

prints :: Show a => [a] -> IO ()
prints as = putStrLn $ concat $ intersperse " " $ map show as

main = do
    n <- readInt
    records <- replicateM n (replicateM 4 readInt)
    let res = go records
    forM_ [1..4] $ \bldg -> do
        forM_ [1..3] $ \flr -> do
            forM_ [1..10] $ \room -> putStr (" " ++ show (res ! (bldg, flr, room)))
            putStrLn ""
        putStrLn (replicate 20 '#')


go :: [[Int]] -> UArray (Int, Int, Int) Int
go records = runSTUArray $ do
    arr <- newArray ((1,1,1), (4,3,10)) 0
    forM_ records $ \[b,f,r,v] -> writeArray arr (b,f,r) . (+v) =<< (readArray arr (b,f,r))
    return arr

