import Data.Array
import Data.List
import Data.List.Split

main :: IO ()
main = interact $ format . calc . map (map read . words) . tail . lines

calc :: [[Int]] -> [Int]
calc = elems . update (listArray (1,120) [0,0..])

update :: Array Int Int -> [[Int]] -> Array Int Int
update arr nss = accum (+) arr (map updInfo nss)
    where updInfo [b,f,r,v] = ((b-1)*30+(f-1)*10+r, v)

format :: [Int] -> String
format = intercalate sep . map unlines . chunksOf 3 . map unwords . chunksOf 10 . map show
    where sep = replicate 20 '#' ++ "\n"
