import Control.Monad
import Data.List
import Data.Array

type House = Array (Int, Int, Int) Int
type Info = ((Int, Int, Int), Int)

initialHouse :: House
initialHouse = array ((1, 1, 1), (b, f, r)) [((i, j, k), 0) | i <- [1..b], j <- [1..f], k <- [1..r]]
  where (b, f, r) = (4, 3, 10)

printHouse :: House -> IO ()
printHouse house = mapM_ putStrLn $ intercalate [replicate 20 '#'] $ [[(' ':) $ unwords $ map show $ [house!(b, f, r) | r <- [1..10]] | f <- [1..3]] | b <- [1..4]]

applyInfo :: Info -> House -> House
applyInfo info@((b, f, r), v) house = house//[((b, f, r), v + house!(b, f, r))]

makeInfo :: [Int] -> Info
makeInfo [b, f, r, v] = ((b, f, r), v)

main :: IO ()
main = do
  n <- readLn
  input <- replicateM n getLine
  let infos = map (makeInfo . map read . words) input
  printHouse $ foldr applyInfo initialHouse infos