import Control.Applicative
import Control.Monad
import Data.Array
import Data.Array.ST
import Data.List
import qualified Data.Map as M
import qualified Data.Set as S
import Text.Printf

readInts :: IO [Int]
readInts = map read . words <$> getLine

main :: IO ()
main = do
  n <- readLn
  bfrvs <- replicateM n readInts
  let ary = solve bfrvs
  forM_ [1..4] $ \b -> do
    forM_ [1..3] $ \f -> do
      forM_ [1..10] $ \r -> do
        printf " %d" (ary ! (b, f, r))
      putChar '\n'
    when (b /= 4) $ putStrLn $ replicate 20 '#'

solve :: [[Int]] -> Array (Int, Int, Int) Int
solve bfrvs = runSTArray $ do
  ary <- newArray ((0,0,0),(4,3,10)) 0
  forM_ bfrvs $ \[b,f,r,v] -> do
    v0 <- readArray ary (b, f, r)
    writeArray ary (b, f, r) (v0 + v)
  return ary

