import Control.Applicative
import Control.Monad
import Data.List
main = do
  n<- (read::String->Int) <$> getLine
  ws <-  map (map (read::String->Int) .words) <$> (replicateM n getLine)
  putStr $ unlines $ drawMap $ foldl (\x y-> zipWith (+) x y) (replicate (10*3*4) 0) (map room ws)

room:: [Int]->[Int]
room [b,f,r,v] = (replicate (pos-1) 0)++[v]++(replicate (10*3*4-pos) 0)
  where pos=(b-1)*30+(f-1)*10+r

chunk :: Int -> [a] -> [[a]]
chunk n [] = []
chunk n xs = ys : chunk n zs
  where (ys,zs) = splitAt n xs

drawFloor:: [Int]->String
drawFloor x = " " ++ ((unwords . map show) x)

drawBlock:: [Int]->[String]
drawBlock x = map drawFloor $ chunk 10 x

drawMap::[Int]->[String]
drawMap x = concat (intersperse [separator] (map drawBlock (chunk 30 x)))

separator:: String
separator= replicate 20 '#'