import Data.Array.ST (STUArray, runSTUArray, newArray, readArray, writeArray)
import Data.Array.Unboxed
import Data.List
import Control.Monad.ST (ST,runST)
import Control.Monad
import Control.Applicative

type HouseFloorRoom = (Int,Int,Int)
type Apartment = UArray HouseFloorRoom Int
type STApartment s = ST s (STUArray s HouseFloorRoom Int)

solve :: [String] -> Apartment
solve lines =
    runSTUArray $ do
        arr <- newArray ((1,1,1),(4,3,10)) 0 :: STApartment s
        forM_ lines $ \line -> do
            let [b,f,r,v] = map read $ words line
            writeArray arr (b,f,r) =<< (+ v) <$> readArray arr (b,f,r) 
        return arr

main :: IO ()
main = do
    let sep = replicate 20 '#' ++ "\n"
    n <- readLn :: IO Int
    ap <- solve <$> replicateM n getLine
    let ((sh,sf,sr), (eh,ef,er)) = bounds ap
    putStr . intercalate sep $
        [unlines [unwords [show $ ap!(h,f,r) | r<-[sr..er]] | f<-[sf..ef]] | h<-[sh..eh]]