import Control.Monad (replicateM)
import Data.Functor ((<$>))
import Data.List (intercalate)

count :: Int -> Int -> Int -> [[Int]] -> Int
count b f r ((b':f':r':v:_):i) =
  if b' == b && f' == f && r' == r
    then count b f r i + v
    else count b f r i
count _ _ _ _ = 0


main :: IO ()
main = do
    n <- readLn
    info <- replicateM n (map read . words <$> getLine)
    let tenant = [[[ count b f r info | r <- [1..10]] | f <- [1..3]] | b <- [1..4]]
    putStrLn . intercalate "\n####################\n" . map (intercalate "\n" . map ((' ' :) . unwords . map show)) $ tenant

