import Control.Monad
import Data.List

count :: (Int, Int, Int) -> [(Int, Int, Int, Int)] -> Int
count t ts = foldl (+) 0 $ map (\(_, _, _, v) -> v) $ filter (\(b, f, r, _) -> t == (b, f, r)) ts

solve :: [(Int, Int, Int, Int)] -> String
solve ts = intercalate separator $ map house [1 .. 4]
    where
        house b   = unlines $ map (line b) [1, 2, 3]
        line b f  = " " ++ (unwords $ map show $ map (\r -> count (b, f, r) ts) [1 .. 10])
        separator = replicate 20 '#' ++ "\n"

main :: IO ()
main = do
    n     <- readLn
    lines <- replicateM n getLine
    putStrLn $ solve $ map ((\[b, f, r, v] -> (b, f, r, v)) . map read . words) lines