{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE OverloadedStrings #-}
import Control.Monad
import Control.Monad.ST
import Control.Monad.Primitive
import Data.Maybe
import Data.Char
import Data.Array
import Data.Array.ST
import Data.STRef
import Data.List
import Data.STRef
import Text.Printf
import qualified Data.ByteString.Char8 as B
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as MV
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector.Unboxed.Mutable as UM

modifyHouse [b,f,r,v] house = house // [((b,f,r), vNew)]
  where
    vNow = house ! (b,f,r)
    vNew = vNow + v

modifyHouseLoop lists house = loop lists house
  where
    loop [] h     = h
    loop (l:ls) h = loop ls h'
      where
        h' = modifyHouse l h

main = do
  n <- readLn
  bfrv <- replicateM n $ fmap (map read . words) getLine :: IO [[Int]]
  let house = listArray ((1,1,1),(4,3,10)) $ repeat 0
      -- bfrv = [[1,1,3,8],[3,2,2,7],[4,3,8,1]]
      house_after = modifyHouseLoop bfrv house

  forM_ [1..4] $ \b -> do
    unless (b == 1) $ putStr "####################"
    forM_ [1..3] $ \f -> do
      unless (b == 1 && f == 1) $ putStrLn ""
      forM_ [1..10] $ \r -> do
        putStr " "
        putStr . show $ house_after ! (b,f,r)
        when (r == 10 && f == 3) $ putStrLn ""

